0

Im new to this forum n new in c# world too, i got this question:

How to draw 3 image in one dropdown item , I got this code from this site

http://www.csharphelp.com/2006/08/combobox-with-images/

I want to add 3 image like this [see image below] in my dropdown control and I got control of those image too like when dropped and click the image it'll do something, or something like that

example image : http://i59.tinypic.com/2viftyf.jpg

Is it possible to make it ? Sorry for my english

Thanks for answer n replay.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364

2 Answers2

1

You could create a new class, which inherits from the drop-down class and override it's paint function (but this is a bit too advanced).

If you are using ASP.NET you could take a look at this answer.
If you are using WinForms, you have to override the paint-function. You could take a look at this post: Placing Images and Strings with a C# Combobox

Edit (after your second comment):

If I understand it correctly you must change those lines:

if (item.ImageIndex != -1)
{
    imageList.Draw(ea.Graphics, bounds.Left, bounds.Top, item.ImageIndex);

    ea.Graphics.DrawString(item.Text, ea.Font, new
        SolidBrush(ea.ForeColor), bounds.Left+imageSize.Width, bounds.Top);
}

into this:

// some code

for (int i = 0; i < 3; i++)
    imageList.Draw(ea.Graphics, bounds.Left + i * imageSize.Width, bounds.Top, i);
    //            your graphics, left offset + i * image width,   top offset, image index

ea.Graphics.DrawString(item.Text, ea.Font, new
SolidBrush(ea.ForeColor), bounds.Left + 4 * imageSize.Width, bounds.Top);
//                           adjust left string offset here

// some code
Community
  • 1
  • 1
unknown6656
  • 2,765
  • 2
  • 36
  • 52
  • I already take a look into those thread, but what I want isn't something like that {please look into picture link} , and again I m not using html or such thing , i'm using pure C# for my program. Any other suggest ? – fajar vashra Jan 11 '15 at 12:00
  • As my understanding from maxscript user view, `` imageList.Draw(ea.Graphics, bounds.Left, bounds.Top, item.ImageIndex);`` code taken from http://www.csharphelp.com/2006/08/combobox-with-images/ I just have to add for loop before imageListxxxx.... and close it. but I don't know how to do it with 3 image on the horizontal position like in my example image. – fajar vashra Jan 11 '15 at 12:15
0

First of all, are you using html?

Html DropDowns, which are select tags, doesn't support his type of customization. You can "fake" this ui by using other html tags and make them look like dropdowns, for example <ul><li> tags.

There are plugins which does this for you, like kendo dropdowns

Catalin
  • 11,503
  • 19
  • 74
  • 147