Solved

Center groupbox in panel

Posted on 2008-10-13
3
1,886 Views
Last Modified: 2013-12-17
VS2008 - Winforms - C#

I am trying to center a groupbox within a panel... what isn't right in this code?


// Center horizontally.
this.grpLogin.Left = (this.panel1.Width - this.grpLogin.Width) \ 2;

// Center vertically.
this.grpLogin.Top = (this.panel1.Height - this.grpLogin.Height) \ 2;
0
Comment
Question by:conrad2010
  • 2
3 Comments
 
LVL 48

Accepted Solution

by:
jpaulino earned 500 total points
ID: 22706717
Try this way instead:
// Center horizontally.
this.grpLogin.Left = (this.panel1.Width - this.grpLogin.Width) / 2;
 
// Center vertically.
this.grpLogin.Top = (this.panel1.Height - this.grpLogin.Height) / 2;

Open in new window

0
 

Author Closing Comment

by:conrad2010
ID: 31505681
I *am* in need of some coffee!
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 22707030
It's Monday :)
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question