如何联系用户控件? [英] How do I contact the user control?

查看:44
本文介绍了如何联系用户控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

紧急帮助!!!

你好

我设计了一个用户控件

我在我的表单中使用了我的控件

我的表格上有一个文本框。

当我点击控件时我想要

在文本框中写入任何东西

我该怎么做?

我是否应该使用这个活动?

怎么样?



我是用C编码

在Visual Studio中



谢谢

Urgent help!!!
hello
I have designed a user control
I used the my control in my form
There is a text box on my form.
I want when I click on the control
write anything into the textbox
How do I do it?
Whether the event should I use?
How?

I am coding with C #
In Visual Studio

Thank you

推荐答案

Obvious船长告诉我们:你需要处理事件点击



会有一些问题:



如果用户控件没有某些子控件,那么创建用户控件毫无意义。然后,如果单击用户控件,通常会单击其中一个子项,而不是用户控件本身。所以,整个问题可能没有实际意义。如果您点击其中一个孩子,您可能需要处理他们的事件,并且通常以不同的方式处理,否则没有必要生孩子。没有孩子? - 再次看到本段的开头( http://en.wikipedia.org/wiki/Recursion [ ^ ]):-)。



实际上,您确实需要处理用户控件的子节点的不同事件,而不是用户控件本身,以获得一些实际上合理的功能。问题是您需要将这些事件公开给用户控件的用户。这很简单,但需要一些工作。



但这是一个不同的故事。如果你到了这一步,请问另一个问题。



-SA
Captain Obvious tells us: you need to handle the event Click.

There will be some issues with that:

It would be pointless to create a user control if it does not have some child controls. And then, if you click on the user control, you typically click on one of the children, not on the user control itself. So, the whole question may not have a practical sense. If you click on one of the children, you might need to handle their events, and usually in different ways, otherwise there is no point to have children. And without children? — see the beginning of this paragraph again (http://en.wikipedia.org/wiki/Recursion[^]) :-).

More practically, you really need to handle different events of the children of the user control, not the user control itself, to get some practically sensible functionality. The problem is that you need to expose those events to the user of the user control. This is simple enough, but it take some work.

But this is a different story. If you come to this point, ask another question.

—SA


这篇关于如何联系用户控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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