没有发送事件的初始控制值 [英] init control value without send event

查看:94
本文介绍了没有发送事件的初始控制值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想在没有事件触发的情况下以窗体的形式初始化控件的值(例如,我想在组合框中选择一个值,但我不希望此init触发事件selectedvaluechanged).我的窗体中有许多带有事件的控件,实际上,初始化进程会通过值初始化触发的不同事件循环.

在VB.NET(VS 2008)中以某种形式初始化控件的值以控制事件的最佳实践是什么? VB6没有这个问题.

谢谢

Hi,

I want to initialize value for a control in a form without the event fire (For example, I want to select a value in a combo-box but I don''t want that this init fire event selectedvaluechanged). I have many controls with events in my forms and actually the init process loops with the different events fired by value initialisation.

What is the best practice to initialize value for control in a form in VB.NET (VS 2008) to control the events? We didn''t have this problem with VB6.

Thanks

推荐答案

首先不要设置事件设计时间.
从设计中删除selectedvaluechanged事件.

使您的代码结构像这样

first of all don''t set event desing time.
Remove selectedvaluechanged event from desing.

Make your code structure like this

public Form1()
{
    InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
      //You can change combobox value even here without calling event
      this.combobox1.ValueChanged += new System.EventHandler(this.numericDiameter_ValueChanged);
}




因此您的初始化将不会调用事件,并且您可以更改值


希望这对您有帮助


快乐编码
:)




so your initialization will not call event and you can able to change value


hope this helps you


happy coding
:)


这篇关于没有发送事件的初始控制值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆