473,399 Members | 3,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Adjusting components size by text and font

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.

Jun 10 '07 #1
1 1395
JR
GetTextExtentPoint32

JR

<Or********@gmail.com???
??????:11**********************@w5g2000hsg.googleg roups.com...
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.

Jun 10 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Marti | last post by:
Dear everyone, Its my understanding that IE6 now uses a default text-size of "Small" rather than IE5's "Medium". Since I have used relative font-sizes (usually in ems) on all my sites, I am...
6
by: Chris McGarry | last post by:
Hello, I am trying to use a heading tag in my pages but want to control the look via a style sheet. I am new at CSS but here's what I have so far: <HTML><HEAD> <STYLE TYPE="text/css"> H1...
2
by: Ian | last post by:
In Windows XP, there's an accessability wizard that allows the user to change the font size for readability. There's probably something similar in other operating systems. I think it would be a...
3
by: Poul C | last post by:
Hello With the code below I can resize all the components on a Form when ever the Form resizes. For the time beeing it dosn't allow a component to contain another component, but with a...
4
by: tshad | last post by:
I am having trouble with links in my DataGrid. I have Links all over my page set to smaller and they are consistant all over the page in both Mozilla and IE, except for the DataGrid. Here is a...
7
by: Daniel Kaplan | last post by:
I have the item below at the top of my style sheet. And it seems that the font-szie is ignored. I know that my linked style sheet is being read, and used because if I remove the font-family line,...
3
by: Adam Smith | last post by:
Hello, How does one adjust the input field size (height) in a form, say to accept 10pt rather than the 12pt txt that apparently is the norm. Thanks --Adam--
18
by: Diogenes | last post by:
Hi All; I, like others, have been frustrated with designing forms that look and flow the same in both IE and Firefox. They simply did not scale the same. I have discovered, to my chagrin,...
14
by: David C. Stone | last post by:
Is there a way in CSS to adjust the baseline position of text marked up with either <sup></supor <sub></sub>, relative to the surrounding text? Reason for asking is that the default rendering in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.