简体   繁体   English

如何将类添加到组合框并应用于图片框?

[英]how to add class to combobox and apply to picturebox?

In C# WinApp, how can I add image class (lowpass filter and highpass filter) to ComboBox?在 C# WinApp 中,如何将图像类(低通滤波器和高通滤波器)添加到 ComboBox? and then apply to PictureBox?然后申请到PictureBox? I did a search and usually, the answers are only shown text.我进行了搜索,通常,答案仅显示文本。 do I have to convert class to string?我必须将类转换为字符串吗? and how do i apply it to PictureBox?以及如何将其应用于 PictureBox? the PictureBox have an image so I want to apply lowpass filter to the image in PictureBox using Combobox PictureBox 有一个图像,所以我想使用 Combobox 将低通滤波器应用于 PictureBox 中的图像

You can do this a couple different ways你可以通过几种不同的方式做到这一点

the first one would be without databinding第一个没有数据绑定

MSDN Add/Remove items to dropdown WF MSDN 添加/删除项目到下拉 WF

Just call打电话就行

comboBox1.Items.Add("Low Pass"); 
comboBox1.Items.Add("High Pass");

on the onload MSDN event in windows forms Windows 窗体中的onload MSDN事件

then on the selectedindex change event you handle what to do when one or the other is selected然后在selectedindex更改事件上处理选择一个或另一个时要执行的操作

you can do this by checking combobox1.text你可以通过检查combobox1.text来做到这一点

if (combobox1.text == "High Pass")
{
  //apply filter
}
else if (combobox1.text == "High Pass")
{
  //apply filter
}

Something else you can look into is databinding MSDN您可以查看的其他内容是数据绑定MSDN

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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