سؤال

Possible Duplicate:
Resize WinForm, with no border?

I want my WinForm application to NOT have any border. But still I want to be able to move the application using mouse, resize the application.

How can I achieve this?

I have gone through some blogs and questions on the Stackoverflow which talk about applying various themes to the WinForm by overriding WndProc method of the Windows Form class. E.g. http://customerborderform.codeplex.com/

Note that I don't want to apply various skins or themes. I just want to make border disappear (or make thickness of the border as small as possible, as if there is just thin border around the main client area of the form). Please note that I do NOT want the title bar at all.

I am using .NET 4.0.

هل كانت مفيدة؟

المحلول

Here is a link from CodeProject on moving a form without a titlebar. Now, I know that in the image it shows a titlebar. But if you download the code, remove the form's Text and set the ControlBox to false; You get a form which is moveable and without a titlebar.

I should note that it still has a thin border (just like you mentioned you want)

Update: After viewing @HansPassant's own answer (which is also a very good solution) - Setting the FormBorderStyle property to None in the CodeProject code completely removes the border and still makes the form moveable:

private void InitializeComponent()
{
    this.Text = String.Empty;
    this.ControlBox = false;
    this.FormBorderStyle = FormBorderStyle.None; 
    ....
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top