TextBox event for only user input

前端 未结 5 965
南旧
南旧 2021-01-12 06:46

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 "D

5条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-12 06:56

    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();
    }
    

提交回复
热议问题