[英]c# Windows 8: Combobox selected item
I have a ComboBox filled with the names of different movies. 我有一个组合框,上面放着不同电影的名字。 (eg Skyfall) When I select 'Skyfall' in the ComboBox I would like to change my Image to the logo of the movie (Images/Skyfall.png) The logo always have the same name as the Title of the movie + .png How could I do this?
(例如Skyfall)当我在ComboBox中选择“ Skyfall”时,我想将我的图片更改为电影的徽标(Images / Skyfall.png)该徽标始终与电影的标题+ .png如何具有相同的名称。我可以这样做吗?
Use ComboBox_SelectedIndexChanged
event. 使用
ComboBox_SelectedIndexChanged
事件。 Set an array of image paths with name ImagePathArray
and store all your paths as string in it. 设置一个名称为
ImagePathArray
的图像路径数组,并将所有路径作为字符串存储在其中。 In the ComboBox_SelectedIndexChanged
change your picturebox.BackgroundImage = System.Drawing.Bitmap.FromFile(ImagePathArray[ComboBox.SelectedIndex]);
在
ComboBox_SelectedIndexChanged
更改图片ComboBox_SelectedIndexChanged
picturebox.BackgroundImage = System.Drawing.Bitmap.FromFile(ImagePathArray[ComboBox.SelectedIndex]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.