how to add an image and item to a imageComboxBoxEdit

Go To StackoverFlow.com

1

I have been trying and trying and looking for ways/tutorials on how to add an image and text item to a imageComboBoxEdit I even read the documentation, but that didn't really help. I used an imageList then I added Resource.Black; to the imageList however when I try to add it to the text via this

private void AddItems(ImageComboBoxEdit editor, ImageList imgList) 
{
    for(int i = 0; i < 10 ; i++) 
        editor.Properties.Items.Add(new ImageComboBoxItem("Item " + (i + 1).ToString(), i, i));
        editor.Properties.SmallImages = imgList;
}

then doing AddItems(imageComboBoxEdit1, imageList1); it works fine for the text items but if I add a bunch of images to the ImageList it just deletes all the text items and doesn't display items in it at all.

Bottom line: I NEED HELP! lol

Any and all help will be appreciated! :D thanks

2012-04-04 22:28
by Ian Lundberg


3

With the designer:

  1. Drop an image list on the form and added an image to it.
  2. In the properties window for the imageComboBoxEdit expand properties set SmallImages to the ImageList added to the form.
  3. Click on the browse button for the Items Property
  4. Click add, to create a new item, fill in description (text to display) and the imageIndex for the image in the image list, and a value. I usually use the same number for the value as the imageIndex.

Or in code, still assuming that the image list was added to the form and has an image in it.

        ImageComboBoxItem someItem = new ImageComboBoxItem();
        someItem.Description = "Text To Display";
        someItem.ImageIndex = 0;
        someItem.Value = 0;

        imageComboBoxEdit1.Properties.Items.Add(someItem);

For this example, I just did this during form load.

2012-04-05 16:21
by Jay
Ads