Click here to Skip to main content
15,914,452 members
Home / Discussions / C#
   

C#

 
AnswerRe: character segmentation [modified] Pin
0x3c013-Mar-09 8:29
0x3c013-Mar-09 8:29 
GeneralRe: character segmentation Pin
Xmen Real 13-Mar-09 8:32
professional Xmen Real 13-Mar-09 8:32 
GeneralRe: character segmentation Pin
0x3c013-Mar-09 8:46
0x3c013-Mar-09 8:46 
Questiongetting http status code Pin
laziale13-Mar-09 6:49
laziale13-Mar-09 6:49 
AnswerRe: getting http status code Pin
led mike13-Mar-09 7:53
led mike13-Mar-09 7:53 
GeneralRe: getting http status code Pin
laziale13-Mar-09 8:07
laziale13-Mar-09 8:07 
Questiongeneric comboBox method Pin
ch0pper113-Mar-09 6:45
ch0pper113-Mar-09 6:45 
AnswerRe: generic comboBox method Pin
J$13-Mar-09 10:02
J$13-Mar-09 10:02 
Maybe something like this will give you a nudge in the right direction...

This example assumes that there are 4 comboboxes, comboBoxA1, comboBoxA2, comboBoxB1, and comboBoxB2. comboBoxA1 will modify the currently selected item in comboBoxB1, and likewise for comboBoxA2 and comboBoxB2. In putting this quick example together, each of the comboboxes have the same exact items in them. You may need to adjust to fit your situation as needed.

This example requires that you stick to some sort of naming convention for the comboboxes (which it appears you do)

public Form1()
{
    InitializeComponent();

    for (int i = 1; i <= 2; i++)
    {
        // Get the "A" combobox
        string name = string.Format("comboBoxA{0}", i);

        // Get reference to the combobox using the name
        ComboBox cbo = (ComboBox)this.Controls[name];

        // Set the tag property to the index of this combobox
        cbo.Tag = i.ToString();

        // Assign an event handler to that comboboxes SelectedIndexChanged event
        cbo.SelectedIndexChanged += new EventHandler(this.ComboBoxA_SelectedIndexChanged);
    }
}

private void ComboBoxA_SelectedIndexChanged(object sender, EventArgs e)
{
    // Get reference to the combobox that caused this event to fire
    ComboBox cboA = (ComboBox)sender;

    // Get the index out of its tag property.  This is so we know how to find the associated "B" combobox
    string index = cboA.Tag.ToString();

    // Get the "B" combobox
    ComboBox cboB = (ComboBox) this.Controls[string.Format("comboBoxB{0}", index)];

    // Set the selected index of the "B" comboBox to the "A" comboBox
    cboB.SelectedIndex = cboA.SelectedIndex;

}

GeneralRe: generic comboBox method Pin
ch0pper117-Mar-09 4:31
ch0pper117-Mar-09 4:31 
QuestionAutomatic Font serialization Pin
baranils13-Mar-09 6:18
baranils13-Mar-09 6:18 
AnswerRe: Automatic Font serialization Pin
led mike13-Mar-09 7:49
led mike13-Mar-09 7:49 
GeneralRe: Automatic Font serialization Pin
baranils13-Mar-09 8:34
baranils13-Mar-09 8:34 
GeneralRe: Automatic Font serialization Pin
led mike13-Mar-09 9:10
led mike13-Mar-09 9:10 
GeneralRe: Automatic Font serialization Pin
baranils13-Mar-09 11:13
baranils13-Mar-09 11:13 
GeneralRe: Automatic Font serialization Pin
led mike13-Mar-09 12:00
led mike13-Mar-09 12:00 
GeneralRe: Automatic Font serialization Pin
baranils13-Mar-09 14:13
baranils13-Mar-09 14:13 
QuestionSending Ctrl+letter to application using PostMesssage or SendMessage Pin
Fredrik Hagg13-Mar-09 5:10
Fredrik Hagg13-Mar-09 5:10 
GeneralRe: Sending Ctrl+letter to application using PostMesssage or SendMessage Pin
Luc Pattyn13-Mar-09 6:26
sitebuilderLuc Pattyn13-Mar-09 6:26 
QuestionAdvice about Open Database Connection Pin
soulidentities13-Mar-09 4:46
soulidentities13-Mar-09 4:46 
AnswerRe: Advice about Open Database Connection Pin
Nagy Vilmos13-Mar-09 4:59
professionalNagy Vilmos13-Mar-09 4:59 
GeneralRe: Advice about Open Database Connection Pin
soulidentities13-Mar-09 5:06
soulidentities13-Mar-09 5:06 
QuestionRe: Advice about Open Database Connection Pin
Nagy Vilmos13-Mar-09 5:12
professionalNagy Vilmos13-Mar-09 5:12 
AnswerRe: Advice about Open Database Connection Pin
soulidentities13-Mar-09 5:17
soulidentities13-Mar-09 5:17 
GeneralRe: Advice about Open Database Connection Pin
Dave Kreskowiak13-Mar-09 5:31
mveDave Kreskowiak13-Mar-09 5:31 
GeneralRe: Advice about Open Database Connection Pin
Nagy Vilmos13-Mar-09 10:30
professionalNagy Vilmos13-Mar-09 10:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.