如何使应用程序实时自动刷新 [英] How do I make an application that refreshes automatically an in real time
问题描述
我有一个我在Vb.net创建的程序。
这个程序是PIC微控制器的计时器计算器。
现在,GUI上有轨迹栏控件,文本框,单选按钮和其他控件。
当一个控件被更改时,根据用户的输入,一个显示输出程序的文本框被更新实时。
我使用< xxxxx> Changed事件作为控件,例如 Text Changed, SelectedIndex 更改并已检查根据控件是文本框,组合框还是单选按钮更改了事件。
我会将所有这些事件硬连接起来我将首先确定发件人的一个函数,然后执行相应的代码。
我假设有更好,更有效的方法来做到这一点,怎么能我这样做了吗?
谢谢
I have a program that I created in Vb.net.
This program is a timer calculator for PIC micro-controllers.
Now,there are trackbar controls, text boxes, radio buttons and other controls on the GUI.
When one control is changed, as per the user's input, a text box showing an output program is updated in real time.
I used the <xxxxx>Changed event for the controls, eg TextChanged, SelectedIndexChanged and CheckedChanged events based on whether the control is a textbox, combobox or radiobutton.
I would hardwire all these events to fire into one function where i would first determine the sender, and then execute the appropriate code.
I assume there is a better, more efficient way to do this, How can i do it?
Thank you
推荐答案
据我所知你有多个控件,其值为chan父节点或上一个控件的值发生变化时的ges。
您可以使用对象参数创建一个函数
As i understand you have multiple controls, whose values changes when a parent or previous control's values changes.
You can create a function with an object parameter
sub (ByVal e as Object)
' all your code here.
' combine all the code here written in TextChanged, SelectedIndexChanged and CheckedChanged events
you can use e to identify the source
end sub.
现在从每个TextChanged,SelectedIndexChanged和CheckedChanged事件中调用此函数。
Now call this function from every TextChanged, SelectedIndexChanged and CheckedChanged events.
我可能不会将它们全部连接到同样的处理:只是因为需要时间来理清哪个控件类型产生了事件 - 你不能使用开关,所以你必须说if(trackbar)then ... else if(textbox)then ...等等。相反,我会为每个控件类使用不同的处理程序,然后将相关信息传递给通用更新程序。
I would probably not wire them all to the same handler: simply because it takes time to "sort out" which control type generated the event - you can't use a switch, so you have to say "if (trackbar) then ... else if (textbox) then ..." and so forth.
Instead, I'd use a different handler for each control class, and then pass the relevant info to a "generic" updater.
这篇关于如何使应用程序实时自动刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!