Reputation: 8491
I've got a System.Windows.Forms.Form where I need to set the size of the client area at runtime. Strangely, though, even when I set the ClientSize property to 800x600, the area is smaller by 4 pixels on the right and bottom sides, which causes my content to be clipped by 4 pixels in both directions.
This behavior is observed with both the Windows XP and Windows Classic themes.
From my understanding of the MSDN documentation this should be doing what I want -- but it's not.
The size of the client area of the form is the size of the form excluding the borders and the title bar.
Sample code here:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.ClientSize = new Size(800, 600);
}
}
What gives? I noticed in the comments of an answer to another question that this is happening to someone else. Is there any way I can set the size of the client area reliably?
Upvotes: 1
Views: 3448
Reputation: 8491
As it turns out, my problem was not with the Form at all. The form has a System.Windows.Forms.WebBrowser control in it -- and that has a border. Since the WebBrowser control doesn't have any border property I didn't suspect it.
Upvotes: 1