|
-
Jul 24th, 2007, 04:41 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] event for any combobox change?
Could some one point me in the direction of how to have multi combo boxes or other controls all fire off the same change event?
-
Jul 24th, 2007, 05:24 PM
#2
Re: event for any combobox change?
You can do that in 2 ways
1- Select the controls you want by holding the "Ctrl" key and clicking on them, then go to the Properties window, switch to the "Events" tab and double click on the event you want.
2- You can go to the Windows Designer generated code, and add to each control the following
Code:
this.ControlName.SelectedIndexChanged += new System.EventHandler(this.ComboBoxesSelectedIndexChanged);
Where 'ComboBoxesSelectedIndexChanged' applies to the "EventHandler" delegate
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jul 25th, 2007, 12:13 AM
#3
Re: event for any combobox change?
Once a method exists you can also select it from the drop-down list for a control in the Properties window. That's important if you create the event handler for multiple controls and then add another control later on.
-
Jul 25th, 2007, 05:51 AM
#4
Lively Member
Re: event for any combobox change?
Please clear ur ques. I am not sure what u want to know.
Please Rate every reply if it is useful to u
-
Jul 25th, 2007, 12:48 PM
#5
Thread Starter
Fanatic Member
Re: event for any combobox change?
What i would like is to consolidate all this into one event
c# Code:
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
Filter(comboBox1.Text, comboBox2.Text, comboBox3.Text);
}
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
Filter(comboBox1.Text, comboBox2.Text, comboBox3.Text);
}
private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
{
Filter(comboBox1.Text, comboBox2.Text, comboBox3.Text);
}
private void comboBox1_TextUpdate(object sender, EventArgs e)
{
Filter(comboBox1.Text, comboBox2.Text, comboBox3.Text);
}
private void comboBox2_TextUpdate(object sender, EventArgs e)
{
Filter(comboBox1.Text, comboBox2.Text, comboBox3.Text);
}
private void comboBox3_TextUpdate(object sender, EventArgs e)
{
Filter(comboBox1.Text, comboBox2.Text, comboBox3.Text);
}
private void Filter(string date, string ref_num, string rootcause)
{
MessageBox.Show(date + " " + ref_num + " " + rootcause);
}
-
Jul 25th, 2007, 02:20 PM
#6
Re: event for any combobox change?
You don't need to pass the ComboBoxes to your method every time if they are always going to be the same ComboBoxes. Your method can look like this:
Code:
private void Filter(object sender, EventArgs e)
{
MessageBox.Show(
this.comboBox1.Text + " " +
this.comboBox2.Text + " " +
this.comboBox3.Text);
}
Then you can, as jmcilhinney suggested, select all your ComboBoxes in design view, open the Properties window and then select your Filter method from the dropdown next to your required events.
-
Jul 25th, 2007, 03:18 PM
#7
Thread Starter
Fanatic Member
Re: event for any combobox change?
works like a charm thanks so much
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|