如何在IDesigner中更改分隔符颜色? [英] How to change separator color in my IDesigner?

查看:88
本文介绍了如何在IDesigner中更改分隔符颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚使用Designer控件创建了自己的库,该控件可从System.ComponentModel.Design参考中使用.所以我在应用程序中有了一个Winform Designer,就像在vs中一样.但是我不喜欢该分隔符白色,我该如何更改它,因为我没有找到分隔色的属性.我知道可以将分隔色更改为灰色,因为Visual Studio分隔色是灰色...图片:第一个图片是设计师中的Visual Studio分隔符,第二个图像是我的IDesignerHost设计器中的难看的白色分隔符.我试图在IDesigner和IDesignerHost中找到分隔符颜色的某些属性,但我没有找到..请帮助我.

我的具有 IDesignerHost 的库如何工作:

 //surface是我实现的设计器的接口,因此我可以将其作为控件//更改基本属性,例如背景色,字体等.//但是我也可以将其作为IDesigner和IDesignerHost获得//但是如何更改分隔符颜色?DesignSurface surface =新的DesignSurface();控制视图= surface.GetView();//返回控件或IDesigner/IDesignerHostview.BackColor = Color.FromArgb(30,30,30); 

解决方案

您可以从

I just created my own library with designer control,that used from System.ComponentModel.Design reference.So i got a winform designer in my application,like in vs.But i dont like that separator white color,how i can change it,because i dont found the property of separator color.I know that is possible to change the separator color like to grey color,because visual studio separator is grey... Image: First image is visual studio separator in designer, Second image is ugly white separator in my IDesignerHost designer.. i we tried to find some property of separator color in IDesigner and IDesignerHost,but i dont found..please help me..

How my library with IDesignerHost is works:

//surface is interface of my implemented designer,so i can get it as control
//to change basic properties,like backcolor,font,etc...
//but also i can get it as IDesigner and IDesignerHost
//but how to change a separator color?
DesignSurface surface = new DesignSurface();
Control view = surface.GetView(); //returns control or IDesigner/IDesignerHost
view.BackColor = Color.FromArgb(30, 30, 30);

解决方案

You can get the splitter from Controls collection of the view of the DesignSurface. The splitter will be added as soon as you have a component in the component tray. So you can use this code to change color of the splitter.

Example

You can try it using the following code. Just make sure you have added a reference to System.Design assembly and using System.Linq and System.ComponentModel.Design namespaces:

var surface = new DesignSurface();
var host = (IDesignerHost)surface.GetService(typeof(IDesignerHost));
surface.BeginLoad(typeof(Form));
var root = (Form)host.RootComponent;
host.CreateComponent(typeof(BindingSource), "bindingSource1");
var view = (Control)surface.View;
view.Dock = DockStyle.Fill;
view.BackColor = Color.White;
var splitter = view.Controls.OfType<Splitter>().FirstOrDefault();
if (splitter != null)
    splitter.BackColor = Color.Red;
else
{
    view.ControlAdded += (obj, args) =>
    {
        if (args.Control is Splitter)
            args.Control.BackColor = Color.Red;
    };
}
this.Controls.Add(view);

And you will get a result like:

这篇关于如何在IDesigner中更改分隔符颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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