Solved

Center groupbox in panel

Posted on 2008-10-13
3
1,875 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

706 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now