Validating source of data in textBox

  • Thread starter Thread starter Angel
  • Start date Start date
A

Angel

How can I validate the source of the data in a textbox? In my program, the
text in textboxY can be changed by the user typing in data or by the user
double-clicking a datagrid (which will copy the data to the textbox). I want
to disable a button if the user enters data manually (not when he/she
double-clicks on grid). How can I distinguish from those two? I wanted to
use TextChanged but they both fire that trigger.

Thank you,
Angel Monson
 
Hello

define 2 boolean flags
private bool inDataGridDblClick;
private bool changedByUser;

in the datagrid dbl click event.

inDataGridDblClick = true;
try
{
myTextBox.Text = ......
}
finally
{
inDataGridDblClick = false;
}

then in the TextBox TextChanged event handler

changedByUser = !inDataGridDblClick;


Hope this helps

Best regards,
Sherif
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top