Adjusting components size by text and font

O

Oron.Morad

Hello,
I develop C#.NET (WinForm) over 2003server.

I am looking for a way to adjust a component size (width pixels)
according to a given text of a certain font (i.e font family, size and
style)

Lets say i have a sentence(english or hebrew), i want the textbox to
expand and minimize if i change the font's size.

Mainly what im looking for is a method that gets the string and the
font parameters (family size and style) and returns the number of
pixels (to set the width of the textbox). If this doesnt exist, then
anything close to that.

I tried using the Size property but it wont do the trick.
I suppose there is either a class in the .Net Framework or an
appropriate GDI/API Function.

For the record, i use the 9Rays fly grid over Framework2, and i need
to automatically adjust the cells size to the text it holds according
to its font (each cell can be adjusted with font and size
imperatively). The fly grid interface does not suffice me with an
approriate method, that is why i turned to this group (If i can get
the calculation of pixels, i can set it to the cell's size).

Thank you very much,
Oron.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top