Winform MDI编程-获得MDI窗体中的MDI控件的方法

 

我的MDI窗体默认是灰色很难看,项目也要求窗体要有背景,我找遍了winform类都没有找到这个MDI背景在哪于是上网搜索了一下,发现原来winform不提供直接的调用,MDI窗口以一个控件的形似放入在winform中,于是乎我在winform类的构造函数中的InitializeComponent()方法后写了遍历窗体中所有控件直到找到这个MDI控件代码如下:
  
public MainForm()
  ...{
            InitializeComponent();
            foreach (System.Windows.Forms.Control myControl in this.Controls)
            ...{
                if (myControl.GetType().ToString() == "System.Windows.Forms.MdiClient")
                ...{
                    bgMDIClient = (System.Windows.Forms.MdiClient)myControl;
                    bgMDIClient.BackgroundImage = img_Logo.Image;
                    break;
                }
            }
  }OK解决问题。
阅读终点,创作起航,您可以撰写心得或摘录文章要点写篇博文。去创作
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Winform MDI是指使用Windows应用程序的多文档界面(Multiple Document Interface, MDI)功能。MDI允许在一个父打开多个子,以在一个应用程序同时处理多个文档或任务。MDI的设置非常简单,只需要将的属性IsMdiContainer设置为True即可。 要在MDI打开子,需要先创建子对象,并将子MdiParent属性设置为父,然后调用子的Show方法显示子。例如,可以使用以下代码在MDI打开Form1: Form1 f3 = new Form1(); f3.MdiParent = this; f3.Show(); 在MDI,还可以使用MdiLayout枚举值来定义子的布局。具包括Cascade层叠排列子、TileHorizontal水平平铺子和TileVertical垂直平铺子。这些布局可以根据用户的需求来选择适合的方式来排列子。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [WinForm——MDI](https://blog.csdn.net/hhhhhhhhhhwwwwwwwwww/article/details/105633316)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [C#winformMDI容器](https://blog.csdn.net/qq_57798018/article/details/128232962)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

heiyandi

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值