4

I have created two buttons with an image inside of them, acting as an icon. By using the ImageBeforeText option in the TextImageRelation property, they look like this:

enter image description here

If I chose an large image for a small button, it would cover the whole button; if I chose an small image for a large button, it would look tiny on comparison. Besides, I'm using a TableLayoutPanel and assigning percentages to each row and column, so all the controls (including those two buttons) are proportional to each other and still look "organized" if the form is resized or a different resolution is used.

That's the problem: As it is, if I resize the form, those two buttons and every other control go along with it (because of the TableLayoutPanel), but the icons in those two buttons don't. Is there a way I can make sure the icons resize as well, so they can be proportional to their buttons?

soulblazer
  • 1,178
  • 7
  • 20
  • 30
  • 1
    Could you share some working demo? I think I understand your problem, but it would be interesting to see the exact `UI` sample. My suggestion is that buttons should never change their size... at most, you would change their alignment, but their size? That doesn't answer your question, though. – Leandro May 23 '15 at 06:10
  • @LeandroTaset My buttons have to change size because my client wants them to change. That's why I'm using the TableLayoutPanel and percentages for each row / column, so the button will resize and fit whenever the form resizes or the resolution changes. I'm reaching for a workaround towards differents resolutions (the TableLayoutPanel / percentages idea is from Microsoft Docs). – soulblazer May 24 '15 at 03:27
  • @soulblazer: That's unfortunate. Now I'm really curious to see at least a mock-up of such `UI`. Your client might just be wrong (they aren't always right, you know). If you still want to comply to their requirement, I think you'd have to create your own custom button with your own paint method. – Leandro May 24 '15 at 04:00
  • @LeandroTaset I know it sounds "hackish", but it's the only way I could find to do a "workaround" of sorts for resolution independency in WinForms (i.e: user resizes the Form or change the resolution and everything stops fitting in the screen, but with that solution fits... well, it does with the resolutions I've tried). It would be easier in WPF, but the client who also happens to be a friend can't buy a newer computer right now. – soulblazer May 24 '15 at 19:21
  • Ah... the infamous DPI! Take a look at http://stackoverflow.com/questions/4075802/creating-a-dpi-aware-application Looks like you are trying to address more than one issue at the same time (or I don't quite get what is your root issue). Also, what version of the .NET Framework are you targeting? WPF applications can run on XP, you just need to install the corresponding Framework version (3.5/4.0 should do). – Leandro May 24 '15 at 21:38
  • @LeandroTaset My client has XP and .NET 3.5, but in my country lots of restaurant owners still have .NET 2.0 (either because their restaurants are small, or they don't have the money, or are not tech-savvy enough). My client / friend will help "promote" the program once is finished and tested by him, but not every restaurant owner around here has .NET 3.5 (some of them have large families). We don't see the point in making 2 versions of the same thing, maybe later... but not right now. – soulblazer May 24 '15 at 23:42
  • I feel your pain. What about the link in my previous comment? Can you solve your problem with any of the solutions suggested to that question? – Leandro May 25 '15 at 02:19
  • 1
    @LeandroTaset Sadly, it didn't, but I ended up making a custom button that resizes the image just fine (using an already created custom button code I found 2 days ago as a guide). Thank you anyway. – soulblazer May 27 '15 at 03:22

1 Answers1

-1

you should set your Button's AutoSize Property to False

  • 2
    How will this make the icon resize? – lloyd May 23 '15 at 11:48
  • 1
    This answer arguably does not address _" Is there a way I can make sure the icons resize as well, so they can be proportional to their buttons?"_ –  May 23 '15 at 12:35