Results 1 to 3 of 3

Thread: C# ComboBox Question

  1. #1
    Silver Member Linedawg's Avatar
    Join Date
    Sep 2005
    Posts
    308

    C# ComboBox Question

    Hello every one I知 in need of some programming advice. I want to use a comboBox in one of my GUI痴 application. The point of the box is to trigger an image to appear inside of a picture box. I know how to build my collections list but I知 at a lost on how I should write the event handler within the combox .

    Here is an example of the code I知 trying

    public void SelectText( string text )
    {
    // Find the index of the specified string.
    int index = comboBox.FindString( text );

    // When the string was not found; add it.
    if( index == -1 )
    {
    index = comboBox.Items.Add( text );
    }

    // Select the string item.
    comboBox.SelectedIndex = index;
    }

    How do I re-write this to trigger a image and sound from the comboBox to the pictureBox.

  2. #2
    Silver Member Linedawg's Avatar
    Join Date
    Sep 2005
    Posts
    308
    Well I don’t know how to do this using a comboBox but I now know how to accomplish the same thing using a buttons. For anyone who is interested this is an example of how I coded the button to link to a pictureBox.

    private void uiTheif_Click(object sender, EventArgs e)
    {
    try
    {
    pictureBox1.Image = new Bitmap(Character.Properties.Resources.Rogue);
    }
    catch
    {
    MessageBox.Show("Error creating image!");
    }

    }

  3. #3
    Security Intelligence TZ Veteran cash_site's Avatar
    Join Date
    Jul 2002
    Location
    Software Paradise
    Posts
    3,735
    Did u work it out?

    Surely you could add the pictureBox1 snippet to your code in the first post?

    The trick with Apps is that everything is an object that can be referenced/accessed from most parts of the code. Most GUI elements are globally defined, so it's easier to write.

    Any good screenshots of your apps?

    --- 0wN3D by 3gG ---

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •