如何从另一个用户控件.cs页面访问用户控件



我搜索了很多。堆栈溢出中有很多问题,如上面的相关标题,但这些问题对我的情况没有帮助。

1.我有一个UserControlA.Design.cs页面。在该页面中,我添加了两个用户控件。它被称为"MyUserControl1"和"MyUserControl2"。
2. 我有一个UserControlB.Design.cs页面。在该页面中,我添加了另一个用户控件。它被称为"MyUserControl3"。具有 Button.I 在 UserControlB.cs 页面中创建按钮单击事件的 MyUserControl3

从这个按钮单击事件中,我必须从UserControlA访问MyUserControl1。

给我一些想法来解决这个问题。提前致谢

编辑:

在UserControlA.Design中.cs页面包含一个名为"MyUserControl1"的用户控件,它包含TreeList。 在 UserControlB.Design.cs 页 包含一个名为 "我的用户控制2" 它包含按钮。 使用该按钮,我必须更改树列表中数据的状态。这就是我想做的。这就是为什么我需要树列表控制按钮单击功能。

您是否尝试通过公共属性从 UserControlA 公开 MyUserControl1?

最新更新