本文介绍了Windows 窗体分隔符控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 VS2010 中我可以在哪里找到水平分隔符控件,可以在 Outlook 设置中找到(下面的屏幕截图)?

https://jira.atlassian.com/secure/attachment/14933/outlook+settings.jpghttp://www.keithfimreite.com/Images/OutlookSettings3.gif

注意:首选 VB.NET,但 C# 可以回答.

解决方案

即使已经回答了这个问题,我还是根据 smoore 的回答发现以下是我所需要的.>

创建一个新控件.编辑代码如下:

public 部分类 Line : Label{公共覆盖布尔自动调整大小{得到{返回假;}}公共覆盖大小 MaximumSize{得到{返回新大小(int.MaxValue,2);}}公共覆盖尺寸最小尺寸{得到{返回新大小(1, 2);}}公共覆盖字符串文本{得到{返回 "";}}公共线路(){初始化组件();this.AutoSize = false;this.Height = 2;this.BorderStyle = BorderStyle.Fixed3D;}}

Line 替换为您想要的控件类名.这将放置一个分隔符,允许您在设计器中调整大小并禁用添加文本,更改自动大小会强制大小的高度为 2,宽度为您想要的任何值,并禁用添加文本.

Where in VS2010 can I find a horizontal separator control, as can be found in Outlook settings (screenshots below)?

https://jira.atlassian.com/secure/attachment/14933/outlook+settings.jpghttp://www.keithfimreite.com/Images/OutlookSettings3.gif

Note: VB.NET preferred, but C# answers okay.

解决方案

Even though this has been answered, I found the following to be what I need based partly on smoore's answer.

Create a new control. Edit the code to be the following:

public partial class Line : Label
{
    public override bool AutoSize
    {
        get
        {
            return false;
        }
    }

    public override Size MaximumSize
    {
        get
        {
            return new Size(int.MaxValue, 2);
        }
    }

    public override Size MinimumSize
    {
        get
        {
            return new Size(1, 2);
        }
    }

    public override string Text
    {
        get
        {
            return "";
        }
    }

    public Line()
    {
        InitializeComponent();
        this.AutoSize = false;
        this.Height = 2;
        this.BorderStyle = BorderStyle.Fixed3D;
    }
}

Replace Line with the control's class name you want. This will put a separator that will allow you to resize in the designer and disables adding text, changing the autosize forces the size's height to be 2 and width to be whatever you want, and disables adding text.

这篇关于Windows 窗体分隔符控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 22:26