C # - How to remove the Maximize, Minimize, but keep a Close button only?

4

I created a graphic component and wrote a command line that removed the control bar from the graphic component, but all the buttons disappeared. Is there any way to just leave the Close button?

Or will I have that Form component type for another?

   
public Form1()
{
     InitializeComponent();
     this.StartPosition = FormStartPosition.CenterScreen;
     this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;                
}
    
asked by anonymous 23.06.2015 / 21:57

2 answers

4

You have two alternatives.

  • Disable the buttons you do not want through the MaximizeBox and MinimizeBox properties by assigning the False value to them.

  • You can modify the style of the form using the FormBorderStyle property as you mentioned using the SizableToolWindow or FixedToolWindow

  • 23.06.2015 / 22:02
    2

    How to do without using code (designer mode only):

    • Open form1.cs
    • click on your form and press F4 to open the properties
    • select "false" for the "MaximizeBox" property
    • select "false" for the "MinimizeBox" property
    • Select "Sizable" for the "FormBorderStyle" property.

    With this, the buttons will remain but will have no effect and your Form can not be resized.

        
    23.06.2015 / 22:12