在列表框C#中插入中等大小的图像
问题描述:
大家好,
我想将图片插入列表框,该列表框将以中等尺寸显示(例如5厘米x 5厘米),然后当我单击其中一张图像时,它将显示在一个较大的图片框中,即在列表的左侧.我可以说像画廊.
我怎样才能做到这一点?有任何想法吗?
hey guys,
I would like to insert pictures to a list box that will be shown in a medium size (for example 5 cm x 5 cm), then when i click on one of the images it''ll be shown in a larger picture box that is to the left of the list. I can say it''s like a gallery.
How can I do that? any ideas?
答
如果您在列表框中以System.Windows.Forms.DrawMode.OwnerDrawVariable
模式使用自定义图形,则可以执行此操作.
请参阅:
http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.drawitem.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system. windows.forms.drawmode.aspx [ ^ ].
请参阅以下讨论:
http://stackoverflow.com/questions/472897/c-sharp-can-i-display-images-in-a-list-box [
You can do it if you use custom drawing in a list box with the modeSystem.Windows.Forms.DrawMode.OwnerDrawVariable
.
Please see:
http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.drawitem.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.drawmode.aspx[^].
Please see this discussion:
http://stackoverflow.com/questions/472897/c-sharp-can-i-display-images-in-a-list-box[^].
You will find a simple code sample in the first answer.—SA