集合编辑器外观 [英] collection editor appearance

查看:59
本文介绍了集合编辑器外观的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建从 CollectionEditor 继承的类后,我可以更改其内部控件的外观,从而访问 关联的 CollectionForm ControlsCollection ,例如

after creating a class inherited from CollectionEditor I was able to change the appearance of its internal controls accessing the ControlsCollection of the associated CollectionForm, e.g.


.Controls[0].Controls[1].Controls[0].BackColor = ... ;

推荐答案

如果您希望每个控件使用不同的背景色,那么您必须按照现在的方式进行操作.但是,如果所有控件的背景颜色都相同,则可以按以下方式递归进行操作.

If you want different background colors for each control, then you have to do the way you are doing it now. But if the background color is same for all controls, you can do it recursively as below.


public void ApplyBackColor(Control oCurrentControl, Color backColor)
{
      oCurrentControl.BackColor = backColor;
      foreach (Control control in oCurrentControl.Controls)
      {
        ApplyBackColor(control, backColor);
      }
}


这篇关于集合编辑器外观的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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