Hello Guys, I am building an application using C# as a front end(VS 2008).
I have a main form which contains a main menu and other controls like labels, calendar etc.. the main form I am talking about starts as full screen, my problem is when I drag/drop/edit controls in design mode and run the application, the controls are not in the same place as i putted them in design mode. [i.e] I placed a calendar in design mode in the center of the form, and another label as a footer, so when i run the application i found the calendar and the label went up few inches up.

Any help would be appreciated.

Recommended Answers

All 6 Replies

Hello Guys, I am building an application using C# as a front end(VS 2008).
I have a main form which contains a main menu and other controls like labels, calendar etc.. the main form I am talking about starts as full screen, my problem is when I drag/drop/edit controls in design mode and run the application, the controls are not in the same place as i putted them in design mode. [i.e] I placed a calendar in design mode in the center of the form, and another label as a footer, so when i run the application i found the calendar and the label went up few inches up.

Any help would be appreciated.

Can you post a screenshot of the problem and any code that you think might be suspect?

If you are using a MDI, the menu might move off of your form and onto the parent form which could make it look different.

The label at the bottom is probably moving because the anchor for it is set to "Top, Left". Try changing it to "Bottom, Left, Right" or something along those lines to keep it in place.

The calendar is probably having the same problem. Maybe set it to "Top, Left, Right"

If you already have the anchor set correctly, the next question I would ask is, are you using any layout tables, panels or anything like that?

Thank you zachattack05, I wasn't familiar with anchor thing, now I edited my controls anchors and the form is having a better look than previous.
Yea I am using panels in other forms, but in this one I prefer something else, can you give me more useful layout tables?

Panels are okay, just remember though, the anchor is only for the the control's parent container. So...if, for example, you have a form with PanelA and a label control LabelA inside that panel, when you set the anchor on the label, it will adhere to the PanelA rules.

I attached an example to show what I mean.

In the example, you can see that the label ignores the size of the window even with the anchor set. It does that because the anchor is relative to the panel, and the panel is set to Top, Left for both. If I changes the panel to "Dock Fill" the form, or if I changed the anchor of the panel, the label would react differently.

Honestly, I find the programming logic, the code writing or whatever you want to call it, MUCH easier than form design...I HATE messing around with layouts...it's so frustrating.

Ok, I got your Idea, and my problem is solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.