How to set Width of Radio Button Automatically?

joshuaand

Well-known member
Joined
Sep 2, 2003
Messages
45
Location
Australia
Hi,

What I am doing is setting the text of a couple of radiobuttons automatically, and I would like to put them up next to each other once the text is set, but there is no autowidth property for the radio button, so I was using "MeasureString" to get text width, but it doesnt work properly, seems to work "OK" for small strings, then you get a large string and its way out.

Any ideas????

thankyou
 
It probably depends on the StringFormat youre using to draw the text. Use the CreateGraphics method of the radio button in question to get the graphics to measure from, then try passing StringFormat.GenericTypographic to the MeasureString method.
 
STill Bad

Hi,

I tried using "StringFormat.GenericTypographic" which made it better but sting very wrong.

Until I get a chance to look at it again I am filling a label with the text, autosizing it and getting the width, and adding 20 for the button.

Dodgy but it works great!
 
Back
Top