通过code无法访问控制 [英] Trouble accessing control through code

查看:124
本文介绍了通过code无法访问控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在试图将项目添加到列表视图。问题...这是不是在目前的形式我的工作。

I am currently trying to add items to a listview. The problem… it is not in the current form I’m working on.

目标项目位于:

Form1
  TabControl1
    Tab2
      SplitPanel1
        Panel1
          listMain

尝试添加项目从位置:

Trying to add items from location:

Form1
  TabControl1
    Tab2
      SplitPanel1
        Panel2
          UserControlForm

我敢肯定这件事情很容易,我失踪,但我似乎无法弄清楚如何从code访问它。

I’m sure it’s something easy I’m missing but I can’t seem to figure out how access it from code.

有没有人有什么建议?这是所有在同一个命名空间...

Does anyone have any suggestions? It is all under the same namespace…

推荐答案

这是不是一个很干净的做法,但它可以做到的。在的WinForms UI控件默认都是私有的,所以理论上讲,你可以打开designer.cs文件,找到控制,并予以公布。不过,我建议一个更好的设计比接近这种方式。

This is not a very clean approach but it can be done. UI controls in WinForms are by default private, so technically you could open up the designer.cs file, find the control, and make it public. However, I'd advise a better design than approaching it this way.

这篇关于通过code无法访问控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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