?
Solved

Center groupbox in panel

Posted on 2008-10-13
3
Medium Priority
?
1,911 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 48

Accepted Solution

by:
jpaulino earned 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

800 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