String Width
-
Is there a simple way to explicitly get the width of text in a control? In general, I would like to dynamically size labels, buttons, listboxes, etc. depending on their contents. I don't have to get the font, draw the text somewhere else and measure it do I? Thanks, -Luther
-
Is there a simple way to explicitly get the width of text in a control? In general, I would like to dynamically size labels, buttons, listboxes, etc. depending on their contents. I don't have to get the font, draw the text somewhere else and measure it do I? Thanks, -Luther
-
That looks like its worth a shot. I guess, if text on a button spans 2 lines, I need to get the "size" of the button's print area. That may be different than the size of the button right? Maybe there is a "client area size" property or something ... In any case, that call starts me off. Thanks, -Luther
-
Ok - I know this is a naive question, but where do I get a graphics object. I am not in an event handler. I am in my custom control's constructor. Its not attached to anything. I just create a button and I've set the Text property, and now I want to set the Size property. It seems that I can't create an instance of the graphics object ... and this is not a static method. I'm not a GDI+ expert but I would guess that I can't just create a Graphics object because there is more to the drawing context that must be defined. Where am I drawing? Which window are we drawing to, etc. Maybe I can must measure the string size in the OnPaint handler (using the parameterized graphics object). Thanks, -Luther