如何获取StatusBarPanel的TextChanged事件 [英] How to get the TextChanged event of a StatusBarPanel

查看:107
本文介绍了如何获取StatusBarPanel的TextChanged事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我试图将TextChanged事件添加到StatusBarPanel,但是该事件不存在.
如何确定何时更改文本?

Hi,

I am trying to add a TextChanged event to a StatusBarPanel but that event does not exist.
How can I determine when the text is changed?

<pre lang="vb">For Each pan As System.Windows.Forms.StatusBarPanel In SB.Panels<br />
     AddHandler pan.TextChanged, AddressOf PanelTextChanged<br />
Next pan</pre>



非常欢迎任何帮助!



Any help is very welcome!

推荐答案

您可以使用数据绑定将StatusBar中的文本与文本框中的文本绑定.比在文本框中的TextChanged事件中添加处理程序
you can use databinding to bind text in your StatusBar with text in textbox.Than add handler to TextChanged event in textbox


此事件确实在StatusBarPanel中不可用.我认为原因是:不需要.在编辑框中,有两种修改文本的方法:由用户和以编程方式进行修改.由于编写StatusBarPanel的唯一方法是编程方式,谁需要此事件?

如果您无事可做,则始终可以使用StatusBarPanel作为基类来创建派生类,并添加此事件.您派生的面板将以与原始StatusBarPanel类完全相同的方式在您的UI中使用.

如果您在两个地方写一些状态文本,肯定会需要保持一致,以避免重复自己( http://en.wikipedia. org/wiki/Don''t_repeat_yourself [ ^ ]).但是在这种情况下,请执行相反的操作:在某些外部上下文(例如表单)上创建一些text属性.在此属性代码的设置程序中,设置的副作用:写入您的(常规)状态栏面板,以及应与状态面板保持同步的其他一些效果.同时,这种方法更容易,更灵活.

—SA
This event is indeed not available in StatusBarPanel. I think the reason is: it is not needed. In edit boxes, there are two way of modification of text: by the user and programmatically. As the only way to write to StatusBarPanel is programmatical, who needs this event?

If you have nothing else to do, you can always create a derived class using StatusBarPanel as a base class and add this event. You derived panels will be used in you UI in exact same way as original StatusBarPanel class.

You certainly need coherency if you write some status text in two places, to avoid repeating yourself (http://en.wikipedia.org/wiki/Don''t_repeat_yourself[^]). But in this case, do just the opposite: create some text property on some outer context, such as you form. In setter of this property code the side effect of the setting: writing to your (regular) status bar panel and some other effect which should be kept in sync with status panel. This approach is much easier and more flexible at the same time.

—SA


我仍然需要一些帮助,因为我无法将处理程序添加到文本框中.是否可以帮助我并发布一些有关如何实现此目标的代码?我也在这里发布了:如何使用数据绑定以将StatusBar中的文本与文本框中的文本进行绑定 [
I still need some help with this, as I can not get the handler to a textbox. Is it possible to help me and post some code on how to achieve this? I also posted here: How to use databinding to bind text in my StatusBar with text in textbox[^]


这篇关于如何获取StatusBarPanel的TextChanged事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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