472,958 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How to get text width and hieght in a richtext box

Hi all,

I have application being written in C# where I have to calculate the
text pixel height and width of the line being typed in rich text box.
I need to get the pixel height of the character next to cursor and the
total length of the row where the cursor is. Rich text box might have
different fonts with different styles I need to get the length in
pixels.
Can some one let me know an easy method ?

Pubdu
Jun 27 '08 #1
4 4649
On Jun 17, 12:25*pm, Pubs <pubud...@gmail.comwrote:
Hi all,

* I have application being written in C# where I have to calculate the
text pixel height and width of the line being typed in rich text box.
I need to get the pixel height of the character next to cursor and the
total length of the row where the cursor is. Rich text box might have
different fonts with different styles I need to get the length in
pixels.
Can some one let me know an easy method ?

Pubdu
Hi,
I do not know how to get it from inside the RichTextBox, but you can
use Graphics.MeasureString , all you need to know is the string and
the Font to use
Jun 27 '08 #2
On Jun 17, 2:50*pm, "Ignacio Machin ( .NET/ C# MVP )"
<ignacio.mac...@gmail.comwrote:
On Jun 17, 12:25*pm, Pubs <pubud...@gmail.comwrote:
Hi all,
* I have application being written in C# where I have to calculate the
text pixel height and width of the line being typed in rich text box.
I need to get the pixel height of the character next to cursor and the
total length of the row where the cursor is. Rich text box might have
different fonts with different styles I need to get the length in
pixels.
Can some one let me know an easy method ?
Pubdu

Hi,
I do not know how to get it from inside the RichTextBox, but you can
use Graphics.MeasureString , all you need to know is the string and
the Font to use
thank you for the replyt
Jun 27 '08 #3
Hi,

Is there a way to scroll the text of the richtext Box to a specific Line number and makes the cursor points to that Line Number?

Thanks,
Dhivya

Sep 8 '08 #4
<Dhivya Rwrote in message news:20*************************@gmail.com...
Is there a way to scroll the text of the richtext Box to a specific Line
number and makes the cursor points to that Line Number?
You should look at the following members of TextBoxBase (from which
RichTextBox derives):

GetFirstCharIndexFromLine
Select
ScrollToCaret

To position the caret in the textbox, you need to "select" zero characters
starting at the position you want to put the caret at.
Sep 8 '08 #5

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

Similar topics

0
by: Thomas | last post by:
Hi! How can i get the optimal richtext width size, when depending on the variable text lengh. The text can be colored or with some differnt fontsizes. I dont want use scrollbars. Is there a...
2
by: PMB | last post by:
Thank you in advance for any and all assistance. I'm trying to input data from strings to a memo field. I would like to know how to check first to see if there is text there currently and if so...
4
by: Mel | last post by:
Hi, When you use a RichText box (I'm using Microsoft Control VB 6.0, OLE Class: RichtextCtrl) It is possible to store only the text in the table instead of the rft format? The problem is when...
1
by: Carlos Lozano | last post by:
I need to merge the content of two richtextboxes. It can not be accomplished using the RichtTextBox.Text field because all format will be lost. So it has to be done using the RichtTextBox.Rtf...
0
by: Stuart Woodard | last post by:
I am struggling to develop a robust mechanism for server-side printing with formatted documents. I need to produce print-spool files from the remote server-side application. This isn't...
5
by: Brian Lowe | last post by:
My web site accepts uploaded photos and stores them in a SQL table as BLObs so they never touch the filesystem. I have a way to create a thumbnail version of the uploaded image and store that in...
4
by: iwdu15 | last post by:
can anybody help me print from a rich text box? i tried the way they showed on the MSDN web page, but it did not work. I am using VB.net 2003...any help would be appreciated
9
by: Rajesh | last post by:
Hi all, Im gonna display a list of images in an aspx page from sql server Db.Each image has a link.When someone clicks the image i want the width and size of the image to be displayed at the...
12
by: Keith G Hicks | last post by:
I have a client that I wrote an MS Access app for quite a few years ago where they need to know the height in inches of a block of text for billing their customers. The MS Access app opens Word in...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.