I try to draw an image from a image list in a combobox when the item is selected.
I am able to draw the image, but when the onSelctedIndexChanged
event finish, i lost my image.
My combobox already have the DrawMode.OwnerDrawFixed
I have a ListImage
control named ImageList with 10 pictures.
For my short example i just need to draw in my combobox the image at position 1 of my ImageList, it's the reason why i get this.ImageList.Draw(g, 0, 0, 1);
protected override void OnSelectedIndexChanged(EventArgs e)
{
base.OnSelectedIndexChanged(e);
if (this.SelectedIndex > -1)
{
var g = this.CreateGraphics();
this.ImageList.Draw(g, 0, 0, 1);
}
}
Probably i am not attach to the right event. Any suggestion?
See the picture bellow with a breakpoint in the IndexChanged after the Draw. It's work, but i lost my image after the event.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…