Click here to Skip to main content
15,912,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want to initialize value for a control in a form without the event fire (For example, I want to select a value in a combo-box but I don't want that this init fire event selectedvaluechanged). I have many controls with events in my forms and actually the init process loops with the different events fired by value initialisation.

What is the best practice to initialize value for control in a form in VB.NET (VS 2008) to control the events? We didn't have this problem with VB6.

Thanks
Posted
Updated 25-Mar-10 7:53am
v2

1 solution

first of all don't set event desing time.
Remove selectedvaluechanged event from desing.

Make your code structure like this

C#
public Form1()
{
    InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
      //You can change combobox value even here without calling event
      this.combobox1.ValueChanged += new System.EventHandler(this.numericDiameter_ValueChanged);
}



so your initialization will not call event and you can able to change value


hope this helps you


happy coding
:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900