Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含不同电影名称的组合框。(例如 Skyfall)当我在 ComboBox 中选择“Skyfall”时,我想将我的图像更改为电影的徽标 (Images/Skyfall.png) 该徽标始终与电影的标题同名 + .png 如何我可以这样做吗?
使用ComboBox_SelectedIndexChanged事件。设置一个带有名称的图像路径数组,ImagePathArray并将所有路径作为字符串存储在其中。在ComboBox_SelectedIndexChanged改变你的picturebox.BackgroundImage = System.Drawing.Bitmap.FromFile(ImagePathArray[ComboBox.SelectedIndex]);
ComboBox_SelectedIndexChanged
ImagePathArray
picturebox.BackgroundImage = System.Drawing.Bitmap.FromFile(ImagePathArray[ComboBox.SelectedIndex]);