473,791 Members | 3,179 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem measuring width of TabPage.Text

..NET 2.0

How do I in the DrawItem event of a TabControl measure how wide the area
displaying TabPage.Text need to be??

For example I've got a tabpage with the text property set to "hello world",
when I run this code it only displays "hello wo"

any suggestions on how to fix this are most welcome

Jeff
Jul 16 '07 #1
2 2914
Jeff,

Assuming you have a Graphics instance for the tab page control in the
event, you can call the MeasureString method on the Graphics instance to get
the width of a particular piece of text.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Jeff" <do***@spam.mew rote in message
news:Od******** *****@TK2MSFTNG P06.phx.gbl...
.NET 2.0

How do I in the DrawItem event of a TabControl measure how wide the area
displaying TabPage.Text need to be??

For example I've got a tabpage with the text property set to "hello
world", when I run this code it only displays "hello wo"

any suggestions on how to fix this are most welcome

Jeff

Jul 16 '07 #2
The tabs are measured using GDI.
Graphics.DrawSt ring() uses GDI+ to draw the text and so it does not always
fit into the GDI measured rectangle.

Use System.Windows. Forms.TextRende rer.DrawText() to draw the Tabs Text.
Unfortunately, GDI text cannot always be rotated (it depends on the font),
so this method fails for left and right aligned tabs.

--
Mick Doherty
http://www.dotnetrix.co.uk/nothing.html
"Jeff" <do***@spam.mew rote in message
news:Od******** *****@TK2MSFTNG P06.phx.gbl...
.NET 2.0

How do I in the DrawItem event of a TabControl measure how wide the area
displaying TabPage.Text need to be??

For example I've got a tabpage with the text property set to "hello
world", when I run this code it only displays "hello wo"

any suggestions on how to fix this are most welcome

Jeff

Jul 16 '07 #3

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

Similar topics

5
5223
by: Richard Muller | last post by:
Hi All, As I recall from Java Swing, I could assign the widths of columns to something like a list control proportionally rather than absolutely. That is, essentially I could assign "weights" x, y and z to the columns respectively of a three-column list control; at run time, the system would calculate the available space for the control and, given that w was determined to be the absolute width of the control, would assign w*x /...
3
2542
by: michael haller | last post by:
In my project i have a textfile witch i import in my c# application. The datas in the textfile i show the datas in the textfile in my datagrid..ok that ist not my problem. Now i have a dataset (dataset.xsd the name is ds_BESR). How i can my datas in the datagrid into this dataset ds_BESR? Please help me...i need that. the reasen is my crystal report get the datas
2
3564
by: CMEDIA_SOUND | last post by:
I have a peculiar problem, I have a tabpage with a label control on it. When i set a background image to the tabpage and drag the label around it has paint issues in that it is slow, granted the image i am using is 5mb!!! HOWEVER... I have inherited the tabpage created an Image reference in it, and overrriden the onPaint method to draw the image now if i press a button that sets the background image of the control
5
2598
by: Jeff | last post by:
IDE: VS 2003 :NET OS: XP Pro My app have a form with a tab-control on it. The tab-control have 2 tabpages. One of the tabpages displays a datagrid, and the other tabpage displays details (order date, name, address etc) about the selected row in the datagrid... My problem is when I enter a new record in the details tabpage (saves data to database), and go back to the datagrid. Only the data from the PM-table
4
2519
by: Jeti [work] | last post by:
I have tab control with several tab pages. Each tab page contains a few textboxes filled dynamicly from the code. Everything goes fine, but every textbox that is located on a tab page that has hot been selected after the form has been activates has no text! Let me try to describe my problem further: TAB CONTROL PAGE PAGE PAGE PAGE ------------------------------------
8
2006
by: David | last post by:
This is something I had never seen before. On an aspx page, upon pressing a link button for which I have an event handler in the code behind, the screen shows nothing but a line that says "true" up in the right upper corner of the browser. I have an XP and had just installed XP Service Pack II...against my better judgment. Please help. Thanks.
8
12069
by: touf | last post by:
Hi, I've a tabcontrol that contains many similar tabpages (exactly the same structure with different information), the tabpages number isn't known in the design time it depends of the data. Is there a way to clone ( copy the structure) a tabpage to create anew one by code? thanks.
6
6625
by: mehdi_mousavi | last post by:
Hi folks, Consider a text containing 200 characters (more or less) including and/or excluding the CR/LF within. I would like to compute the height of this text whenever it's width is limited by X pixels! i.e., what's the height of the mentioned text when it's being automatically word wrapped within a rectangle of WIDTH pixels? How am I supposed to calculate the height required to show the message? TIA, Mehdi
1
2479
by: Jeff | last post by:
Hey ..NET 2.0 I've created a User Control which contain a DataGridView. This User Control is displayed on a TabPage. This TabPage is added to the TabControl during runtime. The problem is this: Lets say if I set the size on the DataGridView to width=400px &
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10419
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10201
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9987
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9023
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7531
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5424
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5552
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2910
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.