Click here to Skip to main content
15,860,859 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am working on project in windows form i want to open form on whole screen thats why i want panel to be on center

What I have tried:

i have tried to align center but nothing happen
Posted
Updated 14-Apr-16 3:35am
Comments
Karthik_Mahalingam 14-Apr-16 4:30am    
have you tried dock?
Member 12323765 14-Apr-16 5:00am    
no i didnt try dock whats that
Karthik_Mahalingam 14-Apr-16 5:13am    
HiAlways click the reply button to ask something to the user. else you comments wont be notified to the concerned member.
dock is used to dock the control to it parent container, irrespective of the parent size.
Member 12323765 14-Apr-16 6:56am    
thnx but i tried it come in center

1 solution

You could always handle it in the forms SizeChanged event.
I didn't work all the math out for you but something like this should work:

private void Form1_SizeChanged(object sender, EventArgs e)
{
this.panel1.Left = this.Width / 2;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900