大家好....现在我对splitcontainer有问题.... [英] HI All....Now I have problem with splitcontainer....

查看:107
本文介绍了大家好....现在我对splitcontainer有问题....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建用于存储splitcontainer面板的类属性....但是我只能存储splitcontainer ...如何存储splitcontainer面板...?你能帮忙吗..?感谢阅读................

I want to Create Class Property for storing splitcontainer panel.....But I can store only splitcontainer...How to store splitcontainer panel...? could you help..? thank for reading................

推荐答案

如果您有一个包含SplitContainer的Windows窗体,并且需要对象(类,窗体,用户控件等)以访问窗体中的SplitContainer,您可以遵循几种策略.

一种方法是在MainForm中定义类型为SplitContainer的Public静态属性:
If you have a Windows Form containing a SplitContainer, and you want objects (Classes, Forms, UserControls, etc.) to have access to that SplitContainer in the Form, there are several strategies you can follow.

One would be to define a Public static Property of Type SplitContainer in the MainForm:
public static SplitContainer MainFormSplitContainer { get; set; }

,然后在Form Load Event中:将MainForm中SplitContainer的实例分配给该静态属性:

And then, in the Form Load Event : assign the instance of the SplitContainer in the MainForm to this static Property:

private void MainForm_Load(object sender, EventArgs e)
{
    MainFormSplitContainer = splitContainer1;
}

您还可以使用其他技术,如果MainForm创建其他对象的实例(Forms,UserControls等),则可以通过将对SplitContainer实例的引用注入这些创建的对象中在MainForm中创建对象时,将SplitContainer实例转换为这些对象中的公共属性.

There are other techniques you could use where, if your MainForm creates the instances of other objects (Forms, UserControls, etc.), you can inject a reference to the instance of the SplitContainer into those created objects by assigning the instance of the SplitContainer to public Properties in those objects, when you create them in the MainForm.


这篇关于大家好....现在我对splitcontainer有问题....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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