Textbox event to know if text is selected?
-
Hi Everyone I have upper level framework that needs to be notified when the user has selected text in a regular textbox. There doesn't seem to be a event to signals that the selected text value has changed. Any suggestions other then a timer that polls the control? Thanks
-
Hi Everyone I have upper level framework that needs to be notified when the user has selected text in a regular textbox. There doesn't seem to be a event to signals that the selected text value has changed. Any suggestions other then a timer that polls the control? Thanks
I think your right, there is no event for selected text, you would have to use key/mouse events or possibly on leave
Never underestimate the power of human stupidity RAH
-
Hi Everyone I have upper level framework that needs to be notified when the user has selected text in a regular textbox. There doesn't seem to be a event to signals that the selected text value has changed. Any suggestions other then a timer that polls the control? Thanks
The quickest way to implement this would be with the MouseUp event. Try this approach: private int selectedTextLength = 0; private int selectionStart = 0; private void textBox1_MouseUp(object sender, MouseEventArgs e) { if (selectionStart != textBox1.SelectionStart || selectedTextLength != textBox1.SelectionLength) { selectionStart = textBox1.SelectionStart; selectedTextLength = textBox1.SelectionLength; //notify framwork... } } Cheers! Richard Blythe
"Make it as simple as possible, but no simpler" Issac Newton