简单粗暴,直接删上干货,在构造方法里直接引用参数传this就可以了,如果解决了你的问题,请不要吝啬你的赞!!!!!!!!!!
#region 禁用下拉框滚轮
private void GetControls1SetMouseWheel(Control fatherControl)
{
Control.ControlCollection sonControls = fatherControl.Controls;
//遍历所有控件
foreach (Control control in sonControls)
{
if (control.Controls != null)
{
GetControls1SetMouseWheel(control);
}
if (control.GetType() == typeof(ComboBox))
{
control.MouseWheel += new MouseEventHandler(ComboBox_MouseWheel);
}
}
}
private void ComboBox_MouseWheel(object sender, MouseEventArgs e)
{
HandledMouseEventArgs e1 = e as HandledMouseEventArgs;//需要强转,否则无法设置handeld
e1.Handled = true;
}
#endregion