setting the value to the combo box

V

Vinki

Hello Evryone,

I am an ASP.net developer. I have this combo box in VB.net (Windows form).I
populated the combo box at the form load event. I have a datagrid on my form,
when the user clicks on a datagrid row, I need to programmaticaly set the
value of the combobox based
on whatever the value is on the datagrid. Everytime I set the value, it get
overwritten by form load event and fill up the combo box again. IN asp.net, I
can avoid it by Ispostback, how can I avaoid it here in windows application.
Any help will be greatly appreciated.
 
M

Mr. Arnold

Vinki said:
Hello Evryone,

I am an ASP.net developer. I have this combo box in VB.net (Windows
form).I
populated the combo box at the form load event. I have a datagrid on my
form,
when the user clicks on a datagrid row, I need to programmaticaly set the
value of the combobox based
on whatever the value is on the datagrid. Everytime I set the value, it
get
overwritten by form load event and fill up the combo box again. IN
asp.net, I
can avoid it by Ispostback, how can I avaoid it here in windows
application.
Any help will be greatly appreciated.


You know when the form is loading. So at the top of form_load code, you set
a global flag bloading = true.

And in the cbox.selctedchange_event, you check if bloading = true. If
bloading = true, you exit the event and not execute the code in the event,
because each load of a line of data into the cbox due to form_load event
is going to firer the cbox_selectedchange event.

If bloading = false, then you execute the code in the event, which means,
if bloading = false, the event fired due to a user making a selection in the
cbox, and the data can be changed or value set based on the selection.

Of course, at the end of the form_load event code, you set bloading = false,
so you are prepared for a user making a change in the cbox, firing the
cbox_selectedchange event and executing the code to set the value needed.


__________ Information from ESET NOD32 Antivirus, version of virus signature database 4197 (20090629) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
 

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

Top