简体   繁体   English

c#Windows 8:组合框选择项

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM