473,324 Members | 2,193 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,324 software developers and data experts.

Size of string in a richtextbox

I have a problem with showing text in a richtextbox
I want to show 3 columns of data and want them to be aligned.
I make sure each string for each column is the same length but since
different characters take up different space in the richtextbox
the columns look like a mess.
It there a simple method to get 2 string to takeup the same space in a
richtextbox?
Example:
Entropy [kJ/(Kg Kelvin)] -8.2602E-002
Heat capacity (Cp) [kJ/(kelvin kg)] 3.0876E+000

The text is first column and the numbers are the second column

Thanks Torben

Feb 20 '08 #1
2 3596
Torben,

Well, you could use a fixed-width font. That will ensure that you can
use spaces to line up the content. Otherwise, you will have to position the
separate elements yourself.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Torben Laursen" <do**@not.workwrote in message
news:17**********************************@microsof t.com...
>I have a problem with showing text in a richtextbox
I want to show 3 columns of data and want them to be aligned.
I make sure each string for each column is the same length but since
different characters take up different space in the richtextbox
the columns look like a mess.
It there a simple method to get 2 string to takeup the same space in a
richtextbox?
Example:
Entropy [kJ/(Kg Kelvin)] -8.2602E-002
Heat capacity (Cp) [kJ/(kelvin kg)] 3.0876E+000

The text is first column and the numbers are the second column

Thanks Torben

Feb 20 '08 #2
On Wed, 20 Feb 2008 16:54:29 +0100, "Torben Laursen" <do**@not.work>
wrote:
>I have a problem with showing text in a richtextbox
I want to show 3 columns of data and want them to be aligned.
I make sure each string for each column is the same length but since
different characters take up different space in the richtextbox
the columns look like a mess.
It there a simple method to get 2 string to takeup the same space in a
richtextbox?
Example:
Entropy [kJ/(Kg Kelvin)] -8.2602E-002
Heat capacity (Cp) [kJ/(kelvin kg)] 3.0876E+000

The text is first column and the numbers are the second column

Thanks Torben
Have you tried using tabs '\t'?

string firstLine = "Entropy [kJ/(Kg Kelvin)]\t\t-8.2602E-002";
string secondLine = "Heat capacity (Cp) [kJ/(kelvin kg)]\t " +
3.0876E+000";
richTextBox1.Text = firstLine + Environment.NewLine +
secondLine + Environment.NewLine;

rossum

Feb 20 '08 #3

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

Similar topics

1
by: vanvee | last post by:
Hi I have a user control that contains a RichTextBox in vb.net. In my program, I create multiple instances of this control (with the RichTextBox being in each one), that appear one above the...
2
by: Hariharan Subramony | last post by:
Hello Guys, I have an important issue and need solution at the earliest. Thanks in advance. I have a RichTextBox named say, ' rtb' that has the text "Hello, I am fine." To place it in the...
2
by: Juan | last post by:
I`m inserting strings in a rich text control using the AppendText method, I would like to change certain parts of the string so, for example, a certain word appears bold and red when inserted. Is...
3
by: **Developer** | last post by:
I need to paste an RTF non-ANSI string into a RichTextBox. I know how to do that if the string were all ANSI characters. But the text contains Unicode characters that have no ANSI equivalent. I...
2
by: **Developer** | last post by:
I don't believe the code below gives the correct string size in inches. Can any one tell me what is wrong? I need to know the size of the string before I add it to the RichTextBox
8
by: Paul | last post by:
Hi, My VB is very rusty I'm afraid! What would be the most efficient way to remove the following ASCII characters from a string? à è ì ò ù À È Ì Ò Ù á é í ó ú ý Á É Í Ó Ú Ý â ê î ô û Â Ê Î Ô...
3
by: =?Utf-8?B?QnJpYW4gQ29vaw==?= | last post by:
In my project I want to search thru a text in a text box or RichTextBox. When I search I want to list all lines that contain the string I am searching for. e.g. one plus four two plus four...
0
by: dfirka | last post by:
Dear Everyone, Using a RichTextBox I need to replace text based on certain RTF codes found into the RTF string I look for certain embedded (hidden) information using: int i =...
4
YarrOfDoom
by: YarrOfDoom | last post by:
Hi I'm trying to get my input from a RichTextBox into a string, but the tabs in my input are left away. Is this a limitation of string, or am I doing something wrong? I'm trying to do this like this:...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.