如何创建在C#中的旗帜面板? [英] How do I create a banner panel in C#?

查看:192
本文介绍了如何创建在C#中的旗帜面板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建自己的自定义控制,基本上是3行1列一个TableLayoutPanel。顶部和底部行包含标签(旗)和中间一行是我将添加其他控件。问题是,当我试图从这个控制建立其它形式/控制,设计师不承认中间面板。我如何得到它?如果我拖到一个文本框的中间,设置码头=填充,它会覆盖entrie形式/控制。此外,有没有什么办法让设计师拒绝控件拖动到顶部和底部(旗)的行?我试着在下面的链接中的步骤,但还没有任何运气(的 http://support.microsoft.com/?scid=kb%3Ben-us%3B813450&x=21&y=15 )。

I want to create my own custom control that is basically a TableLayoutPanel with 3 rows and 1 column. The top and bottom rows will contain labels (banners) and the middle row is where I will add other controls. The problem is that when I try to build other forms/controls from this control, the designer doesn't recognize the middle panel. How do I get it to? If I drag a textbox to the middle and set Dock=Fill, it will cover the entrie form/control. Also, is there any way to get the designer to reject dragging of controls to the top and bottom (banner) rows? I've tried the steps in the following link but haven't had any luck (http://support.microsoft.com/?scid=kb%3Ben-us%3B813450&x=21&y=15).

推荐答案

我想通了。诀窍是创建自己的设计师,从ParentControlDesigner继承并重写初始化方法和内部内容面板调用EnableDesignMode。在此之上,我需要我的用户控件的设计属性设置为这个新的设计。细节这里显示

I figured it out. The trick was to create my own designer that inherits from ParentControlDesigner and overrides the Initialize method and calls EnableDesignMode for the inner content panel. On top of this, I needed to set the Designer attribute of my user control to this new designer. The details are shown here.

一个问题,虽然。我可以拖动控制,以我创建的内容面板,一切都看起来很好。但是,一旦我重新编译,控件消失。它们还在那里,我只是觉得他们要的旗帜面板之前绘制。我会为这个问题的一个单独的线程。

One problem, though. I can drag controls to the content panel I created and everything looks fine. But, once I recompile, the controls disappear. They are still there, I just think they're getting drawn before the banner panel. I will create a separate thread for this problem.

这篇关于如何创建在C#中的旗帜面板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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