i have text box user shouldn't allowed write spaces in.
so far have code:
private void searchcriteria_keydown(object sender, system.windows.input.keyeventargs e) { if (e.key.tostring() == "space") { dellast = searchcriteria.text; needstodelete = true; } } private void searchcriteria_keyup(object sender, system.windows.input.keyeventargs e) { if (needstodelete == true) { searchcriteria.text = dellast; needstodelete = false; } } it works, cursor being placed in front of text. there way this?
save selectionstart in onkeydown event , set again within onkeyupevent
private void searchcriteria_keydown(object sender, system.windows.input.keyeventargs e { if (e.key.tostring() == "space") { dellast = searchcriteria.text; needstodelete = true; _selectionstart = searchcriteria.selectionstart; } } private void searchcriteria_keyup(object sender, system.windows.input.keyeventargs e) { if (needstodelete == true) { searchcriteria.text = dellast; searchcriteria.selectionstart = _selectionstart; needstodelete = false; } }
Comments
Post a Comment