i have a richtextbox where the user inputs his/her name.. This needs to always be 60pixels wide, regardless of text..

ie: Johnathon

or Tim

need to be resized to best fit the control.

i've looked on the net, but only found VB solutions. Is there a way to achieve this?..


Thanks..

As far as I know, the code in VB may be replaced with a similar code in C#. But, I doubt if playing with font size is a handy idea. Dunno about others, but I, personally, look cautious at web elements, who are living with their own life =) E.g. changing it's size or placement, so I need to wait till the "magic" would finish and then try continue to work.

It's just MHO .. and maybe in your case it's needed, but I decided to share my concerns :)

P.S. Here's what I've found in C#: C# Tutorial - Font Scaling

yes, i agree with you antenka. i've now changed it, so the user can scale the font to the desired size, then i just output the text using the current font size etc.. now i just have to figure out finding the textbox's current X,Y, then adding these values in a pdf which is using "mm" units.. :/ argh!.. stupid idiot proof program!

ps.. you wouldn't know which is better to use..

textbox.bounds.location.x? or
textbox.location.x?
or another method to get the current X Y of the textbox?..

they both work, but i get odd results when the user moves the textbox a few times..

anyways, thanks for the reply.. :)

Hello,
as MSDN says,

Control.Bounds Property: Gets or sets the size and location of the control including its nonclient elements, in pixels, relative to the parent control.

and

Control.Location Property: Gets or sets the coordinates of the upper-left corner of the control relative to the upper-left corner of its container.

If you're ok with a Location, you probably should use it. If you need something more than upper corner coords - use Bounds :)

This question has already been answered. Start a new discussion instead.