Event that caused checkbox to fill?

  • Thread starter Thread starter Vaughn
  • Start date Start date
V

Vaughn

I have a textbox in my Win form that can be filled when a user chooses an
emplcode from a combobox and when the value is returned from another form
(double-clicks on a separate listbox).
What event can I use to find out how the textbox got filled? In my case, if
the textbox is filled when the user double-clicked on a separate listbox,
I'd like to run VerifyEmp() method. If it's via the combobox or by hand, I
don't do anything.
Someone suggested validating/validation events but I have no idea how to use
them.

Thanks.
 
Hi,

I don;t think that you can do this from the TextBox's point, all you can
see is that the text was changed (TextChanged event), no where the
TextBox.Text was set.

Now I can think of a possible solution:

Make the check in the handlers of the other controls when needed, in the
double click event of the listbox for example.


Cheers,
 
Thanks for your reply.
I didn't really understand what you meant with making the check in the
handlers of the other controls.
If I pass the whole form as reference, do I have access to all of its
controls? Or do I need to pass all the controls as reference?

Vaughn

PD - In the subject line, it's supposed to be "textbox", not "checkbox".
 
Hi Vaughn,

What I meant is that you inside the handler for the TextBox's TextChanged
event you cannot know what method provoked the event.
If you need to verify the value you have two path:
1- Always verify it, unless that your validation code is slow you should
always check it.
2- Put the checking responsability to the event that needs validation ont he
DoubleClick event of the ListBox.

Now you said this listbox was on another form , therefore for you to have
access to the original form's TextBox you could pass either the TextBox
instance of a reference to the whole form, if you do the latter you need to
define either the TextBox as public or implement a property that return it.

I would pass only the TextBox reference.


Hope this help,
 
Back
Top