0

I have 3 buttons in my form. What I need to do is when I make the actual form bigger or smaller, the buttons should change their position and size so they look good, so they wouldn't remain the same size and position. I tried to use the anchors, but that does not work very well. What can I use to solve my problem?

2
  • @Nalaka526 probably stupid question, but what's WCF? And if I understood correctly- i'm using Windows Forms Applications.
    – MarisP
    Dec 30, 2013 at 8:57
  • Sorry, not WCF its WPF (edited already) :)
    – Nalaka526
    Dec 30, 2013 at 8:58

4 Answers 4

0

You can check dock and anchor properties

http://www.youtube.com/watch?v=afsx1IJULLI

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.dock(v=vs.110).aspx

0

You should set both left and right, or top and bottom anchors to resize control. If you'll set only one anchor from these pairs, then control will be positioned instead of resizing.

Docking will resize control, because it is equivalent of setting three or more anchors.

3
  • I think I didn't really explain what I'm trying to achieve. I don't want to fill the entire form with the buttons (if i'll use the anchors it will do that). I want them to just be a little bit bigger or smaller (depends on how big the actual form is). Hopefully I made my problem a bit clearer.
    – MarisP
    Dec 30, 2013 at 9:03
  • @user3137498 so, you want to have several discrete sizes of buttons which will be applied according to form size? Dec 30, 2013 at 9:43
  • @MarisP there is no built in functionality for what you want, and actually I have never seen discrete controls resizing on winforms (well, except integral height setting for listbox). I think if you will provide several screenshots of what you trying to achieve then your intent would be more clear, and some custom solution will be found Dec 30, 2013 at 10:47
0

Try using TableLayoutPanel, put your buttons inside the columns of the table

0

Look good is different all the time. I like placing buttons in StackPanel and setting AutoSize property to true. This fixes two issues:

  1. If user has 150% font in Windows settings - your UI does not break;
  2. if you resize window to be very small - your buttons do not enforce minimal width/height and adapt to ratio user has chosen

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.