473,387 Members | 1,512 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,387 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 4688
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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,...
0
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...

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.