Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TextBox event for only user input

Tags:

c#

events

textbox

I have a Textbox control which sometimes updated programmatically and also can be update by the user. How can I distinct between those two event? I'd like to have a "Dirty" flag set to "True" when the user changes the text.

like image 887
kaycee Avatar asked Mar 12 '11 00:03

kaycee


1 Answers

Check Modified property of TextBox on the TextChanged event. If true, the changes were made by user, otherwise the text was changed programmatically.

Example:

void Texbox_TextChanged(object sender, EventArgs e)
{
    if (((TextBox)sender).Modified)
        TextboxUserInput();
}
like image 63
Oleksandr V. Kukliuk Avatar answered Oct 06 '22 09:10

Oleksandr V. Kukliuk