Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Forms Separator Control

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.jpg http://www.keithfimreite.com/Images/OutlookSettings3.gif

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

like image 204
Steven Avatar asked May 16 '11 19:05

Steven


People also ask

How do I dock controls in Windows Forms?

Select the control in the designer. In the Properties window, select the arrow to the right of the Dock property. Select the button that represents the edge of the container where you want to dock the control. To fill the contents of the control's form or container control, press the center box.

How do I add different controls to my form?

Add the control by drawingSelect the control by clicking on it. In your form, drag-select a region. The control will be placed to fit the size of the region you selected.

What are controls in Windows form?

Windows Forms controls are reusable components that encapsulate user interface functionality and are used in client-side, Windows-based applications. Not only does Windows Forms provide many ready-to-use controls, it also provides the infrastructure for developing your own controls.


2 Answers

If I'm not mistaken, that's just a Line control, but I don't think that control exists anymore. Here is a workaround.

label1.AutoSize = False
label1.Height = 2
label1.BorderStyle = BorderStyle.Fixed3D
like image 62
Seth Moore Avatar answered Oct 13 '22 04:10

Seth Moore


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.

like image 36
Gabriel Graves Avatar answered Oct 13 '22 02:10

Gabriel Graves