如何以编程方式更改继承的用户控件的布局? [英] How to programtically change the layout of an Inherited User Control?

查看:80
本文介绍了如何以编程方式更改继承的用户控件的布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 我有一个具有常见行为的继承用户控件。然后我根据需要在派生控件中专门控制。




  class  BaseControl:UserControl 
{
// common
}

class RedControl:BaseControl
{
// special
}

class BlueControl:BaseControl
{
// special
}


解决方案

< blockquote>

您是否已将splitContainer添加到基本控件?也许问题是splitContianer没有被添加到基本控件中,所以按钮也不会显示。


另一方面,我认为你可以添加一个基于基本控制并使用控件作为参数。在子控件中,你可以像Base.addButtonToBase(yourButtonObject);


也许你可以为该方法做一个扩展,当你想添加一个控件时,做基于int的方法他控制孩子,这应该是任何一种控制的常用方法。


希望它有所帮助。


 I have an Inherited User Control which has common behavior. I then specialize the control as needed in derived controls.

class BaseControl : UserControl
{
 // common
} 

class RedControl : BaseControl
{
 // specialized
}

class BlueControl : BaseControl
{
 // specialized
}


解决方案

Have you added the splitContainer to the base control? Maybe the issue is that the splitContianer did not be added to the base control, so the button will not shown either.

On the other hand, I think you can add a based method in the base control and use a control as a parameter. In the child control, you can do like Base.addButtonToBase(yourButtonObject);

Maybe you can do an extention for that method and when you want to add a control, do the based method int he child control, that should be a common method for any kind of controls.

Hope it helps.


这篇关于如何以编程方式更改继承的用户控件的布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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