Greetings again friends!

It's been a while since I've visited. I had to take a while off from working because of family issues, but things are getting better and I'm starting to work again and that means I get to come back and exchange Q&A with the best programming web group out there!

So...I have a question and was hoping someone might be able to throw a few cents my way.

To clarify, I am not a great GUI designer, I write code, not align things and make it look pretty.

I am writing a customizable dialog box for a library of controls. The window consists of a TableLayoutPanel control with 2 rows and 3 columns all set to "Auto Size" themselves based on content.

The problem I have is, the columns are aligned in auto size mode to the right in a 25%, 25%, 50% type of layout...I need it reversed.

Here's a screen shot from the designer:
Capture10
and here's a screen shot with example text:
Capture12
and the standard message box with the same sample text:
Capture13

Despite the obvious design differences, the buttons are the problem.

I can't set the columns to an exact size since the user is allowed to indicate how many buttons to show, and what the button text will say, so if the user says "show button 1 and make it say 'Click here to blow the entire world up'" it needs to fit so button2 can also appear with custom text as well and the same for button3.

The option of using % for column widths obviously has issues with spacing, so that's definately not an option (unless you guys know something I don't).

The only solutions I have been considering (but have not tested yet, I wanted to solicit ideas first before I waste time writing methods that might not work) are to use the fixed column widths and programmatically change the widths by setting the button text and then getting the button widths and adjusting the columns after, the last step before showing the dialog. But I am worried that if I set the widths that way, when I query the button size it will give me the button size that it will be rendered at and won't work. For example, the dialog box by default (on the designer) is 290x141, and that leave the columns about 96.6 pixels each (margins not included or window thickness I know, its just quick math here).

I'm worried that if the button is supposed to be say 150 pixels that when I query for the size it will just give me 96.6 insted of 150.

Any ideas or solutions you care to share?

Correction: The columns are aligned in a 25%, 25%, 50% fashion to the left, not right.

I think I may have solved the problem myself by changing the first column's width to 100% and the other 2 to autosize. That seemed to fix the problem!

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.