Click here to Skip to main content
15,886,833 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am working on windows application. My form is MDI form. In my form I have two panel,two button like "TOTAL" and "CUSTOMER". So when i am clicking the TOTAL button the total panel should display and when to CUSTOMER the customer panel should display respectively. I have sqiz dt panel into small size in design mode and For that i have written in code,
C#
private void btnTotal_Click(object sender, EventArgs e)
{
   panelTotal.Visible = true;
   panelTotal.Location = new Point(8, 449);
   panelTotal.Size = new Size(634, 118);
}

So my problem is before doing my form as MDI it was working perfectly but after making MDI, it's not working. If i'll set in design mode it's Ok but if hv mentioned in code its not working. It messed up my design. So please help me to solve this problem. I'll be grateful to you.

Thanks.
Posted
Updated 31-Jul-13 22:49pm
v3
Comments
Sushil Mate 1-Aug-13 4:51am    
yes because of the size & location you have hard coded there.
Shivani Dash 1-Aug-13 5:38am    
Thanks Sushil for replyg..then wht shud be d solution?

1 solution

There are some properties of form for setting up the location of the controls on form. Even Control has the Control.Dock[^] & Control.Anchor[^] for setting up the controls position.

Size & Location which you added hard coded will not work on every system, As you might know every system might have different resolution. What if User Change the size of the form?

There are some property of controls which help you to set up the controls.
Control.Top[^]
Control.Left[^]
Control.Right[^]

Why don't you consider the MDI form's Control.Height[^] & Control.Width[^] property for setting up the location of the panel. Have a look here.[^] Even you can use Left & Right property of MDI form to set up the location of the panel, Have a look here.[^]

There are some Answer related to your issue.

1) http://stackoverflow.com/questions/2414377/change-the-size-of-the-panel-dynamically[^]
2) http://stackoverflow.com/questions/968728/update-label-location-in-c[^]
3) http://www.java2s.com/Tutorial/CSharp/0460__GUI-Windows-Forms/ControlSizeandLocationDynamic.htm[^]

Hope this helps.
 
Share this answer
 
Comments
Shivani Dash 1-Aug-13 6:40am    
Thank you so much for your suggestion.. :)
I am going through..n let u knw after dt..
Sushil Mate 1-Aug-13 6:41am    
Sure.
Shivani Dash 1-Aug-13 8:46am    
while m running my page it bcums so larger n vast.Is dt the reason dt i hv to set the form aftr mkng MDI n den d panel?
Sushil Mate 1-Aug-13 9:53am    
no, You can the MDI forms height & width devide by 2, assign that value both panel.

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