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

Using Rich Text Box - make a line bold

If I've got

Me.RichTextBox1.Text = "In Ricn Tex Box"
Me.RichTextBox1.Text &= "Line two" & vbCrLf
How do I make the first line appear BOLD?
Feb 14 '06 #1
9 54321
It is a very interesting question. I am working on that too.
I would like to know also how could we make PORTION of a line Bold ?
I am looking to a solution like:
RichTextBox1.text="In
ricn"&please_make_the_following_bold...&"Text"&mak e_the
following_not_bold_anymore...&"Box"
I am looking for a solution to build nice reports on screen as I was doing
under Basic for DOS 7.1
--
Super Basic programmer under DOS since 1983. Absolutely dummy VB.NET
programmer under Windows !

But it's going better now !
Feb 14 '06 #2
"Jason" <ja***@someone.com> schrieb
If I've got

Me.RichTextBox1.Text = "In Ricn Tex Box" Me.RichTextBox1.Text &=
"Line two" & vbCrLf
How do I make the first line appear BOLD?

http://msdn.microsoft.com/library/en...ClassTopic.asp

Armin

Feb 14 '06 #3
I already have read that segment of the documentation. It is just not easy to
understand for a beginner. How can we select text or portion of text ? We
just have no idea !

I have try to use Word and to save a report to a rtf file format: when
loaded into a Rich Text Box, all the controls characters were shown... I gave
up !

A step by step approach will be very appreciated.
--
Super Basic programmer under DOS since 1983. Absolutely dummy VB.NET
programmer under Windows !
Feb 14 '06 #4
"Jason" <ja***@someone.com> schrieb:
Me.RichTextBox1.Text = "In Ricn Tex Box"
Me.RichTextBox1.Text &= "Line two" & vbCrLf

How do I make the first line appear BOLD?


\\\
With Me.RichTextBox1
.Select(10, 20)
.SelectionFont = _
New Font(Me.RichTextBox1.SelectionFont, FontStyle.Bold)
End With
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Feb 14 '06 #5
Mr Wagner,
It is working very well. I've got lost with the With End With, to give you
an idea of how far we have to go, as beginners...

--
Super Basic programmer under DOS since 1983. Absolutely dummy VB.NET
programmer under Windows !
"Herfried K. Wagner [MVP]" wrote:
"Jason" <ja***@someone.com> schrieb:
Me.RichTextBox1.Text = "In Ricn Tex Box"
Me.RichTextBox1.Text &= "Line two" & vbCrLf

How do I make the first line appear BOLD?


\\\
With Me.RichTextBox1
.Select(10, 20)
.SelectionFont = _
New Font(Me.RichTextBox1.SelectionFont, FontStyle.Bold)
End With
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Feb 14 '06 #6
Hi,

Mr. Herfried Wagner already answered it perfectly, but I will elaborate,
since someone asked for a "step-by-step" method.

1. If you want to make changes to a particular set of text in the RTBox,
just select that text using the
RTB.Select(start,length) method.
If some text is already selected in the RTBox, and you want to change that
text, then you don't need
to apply the above line.

2. Create a Font object setting properties as required.
Dim myFont as new Font("Arial", 12, FontStyle.Bold)

3. Apply that Font object to the RTB.SelectionFont property. You should see
the changes in the RTB.

If RTB.SelectionFont.Bold = False Then
RTB.SelectionFont = myFont
End if

Hope this helps,

Regards,

Cerebrus.
================================================== =======================
"Jason" <ja***@someone.com> wrote in message
news:Ol**************@TK2MSFTNGP14.phx.gbl...
If I've got

Me.RichTextBox1.Text = "In Ricn Tex Box"
Me.RichTextBox1.Text &= "Line two" & vbCrLf
How do I make the first line appear BOLD?

Feb 14 '06 #7
"Marcel Saucier" <Ma***********@discussions.microsoft.com> schrieb
I already have read that segment of the documentation. It is just
not easy to understand for a beginner. How can we select text or
portion of text ? We just have no idea !

I have try to use Word and to save a report to a rtf file format:
when loaded into a Rich Text Box, all the controls characters were
shown... I gave up !

A step by step approach will be very appreciated.

I have never done it yet, but here are some better instructions how to do
it:

http://msdn.microsoft.com/library/en...Attributes.asp

See also the link in the hints sections at the bottom (pointing to the
Textboxbase.Select method).
Armin

Feb 14 '06 #8
Ok, Maybe I'm worse off then a beginner

I've got my Rich Text Box on my Form. The information I'll be displaying is
simple computer properties. I want to display a heading for each section in
BOLD

for Example

Me.RichTextBox1.Text = "HEADING ONE"
Me.RichTextBox1.Text &= "Property one" &VAR1 & vbCrLf
Me.RichTextBox1.Text &= "Property one" & VAR2 & vbCrLf
Me.RichTextBox1.Text &= "Property one" & VAR3 & vbCrLf
Me.RichTextBox1.Text &= "HEADING TWO" & vbCrLf

I'd like to simple have HEADING ONE and HEADING TWO displayed in bold.
How do I do that?
"Cerebrus99" <zo*****@sify.com> wrote in message
news:OJ*************@TK2MSFTNGP15.phx.gbl...
Hi,

Mr. Herfried Wagner already answered it perfectly, but I will elaborate,
since someone asked for a "step-by-step" method.

1. If you want to make changes to a particular set of text in the RTBox,
just select that text using the
RTB.Select(start,length) method.
If some text is already selected in the RTBox, and you want to change that
text, then you don't need
to apply the above line.

2. Create a Font object setting properties as required.
Dim myFont as new Font("Arial", 12, FontStyle.Bold)

3. Apply that Font object to the RTB.SelectionFont property. You should
see
the changes in the RTB.

If RTB.SelectionFont.Bold = False Then
RTB.SelectionFont = myFont
End if

Hope this helps,

Regards,

Cerebrus.
================================================== =======================
"Jason" <ja***@someone.com> wrote in message
news:Ol**************@TK2MSFTNGP14.phx.gbl...
If I've got

Me.RichTextBox1.Text = "In Ricn Tex Box"
Me.RichTextBox1.Text &= "Line two" & vbCrLf
How do I make the first line appear BOLD?


Feb 14 '06 #9
Alrighty, here you go... Copy and paste the following code...
------------------------------------------------------------
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim Var1, Var2, Var3, MyText As String
Var1 = " is good"
Var2 = " is better"
Var3 = " is the best"
MyText = "HEADING ONE" & vbCrLf
MyText &= "Property one" & Var1 & vbCrLf
MyText &= "Property one" & Var2 & vbCrLf
MyText &= "Property one" & Var3 & vbCrLf
MyText &= "HEADING TWO"
RTB.Text = MyText
MakeBold()
End Sub
Private Sub MakeBold()
Dim myFont As New Font("Tahoma", 10, FontStyle.Bold)
'Find Location of "Heading1"
Dim txt2Srch As String = "HEADING ONE"
Dim loc As Integer
loc = InStr(1, RTB.Text, txt2Srch, CompareMethod.Text)
If loc > 0 Then
'The string was found at loc
RTB.Select((loc - 1), txt2Srch.Length)

If RTB.SelectionFont.Bold = False Then
RTB.SelectionFont = myFont
End If
End If

'Repeat procedure for "HEADING TWO"
txt2Srch = "HEADING TWO"
loc = InStr(1, RTB.Text, txt2Srch, CompareMethod.Text)
If loc > 0 Then
'The string was found at loc
RTB.Select((loc - 1), txt2Srch.Length)
If RTB.SelectionFont.Bold = False Then
RTB.SelectionFont = myFont
End If
End If
'Move the caret back to start.
RTB.Select(0,0)

End Sub
------------------------------------------------------------

I think this should get you up to speed. Cheers !

Regards,

Cerebrus.

===========================================
"Jason" <ja***@someone.com> wrote in message
news:OY*************@tk2msftngp13.phx.gbl...
Ok, Maybe I'm worse off then a beginner

I've got my Rich Text Box on my Form. The information I'll be displaying is simple computer properties. I want to display a heading for each section in BOLD

for Example

Me.RichTextBox1.Text = "HEADING ONE"
Me.RichTextBox1.Text &= "Property one" &VAR1 & vbCrLf
Me.RichTextBox1.Text &= "Property one" & VAR2 & vbCrLf
Me.RichTextBox1.Text &= "Property one" & VAR3 & vbCrLf
Me.RichTextBox1.Text &= "HEADING TWO" & vbCrLf

I'd like to simple have HEADING ONE and HEADING TWO displayed in bold.
How do I do that?
"Cerebrus99" <zo*****@sify.com> wrote in message
news:OJ*************@TK2MSFTNGP15.phx.gbl...
Hi,

Mr. Herfried Wagner already answered it perfectly, but I will elaborate,
since someone asked for a "step-by-step" method.

1. If you want to make changes to a particular set of text in the RTBox,
just select that text using the
RTB.Select(start,length) method.
If some text is already selected in the RTBox, and you want to change that text, then you don't need
to apply the above line.

2. Create a Font object setting properties as required.
Dim myFont as new Font("Arial", 12, FontStyle.Bold)

3. Apply that Font object to the RTB.SelectionFont property. You should
see
the changes in the RTB.

If RTB.SelectionFont.Bold = False Then
RTB.SelectionFont = myFont
End if

Hope this helps,

Regards,

Cerebrus.
================================================== ======================= "Jason" <ja***@someone.com> wrote in message
news:Ol**************@TK2MSFTNGP14.phx.gbl...
If I've got

Me.RichTextBox1.Text = "In Ricn Tex Box"
Me.RichTextBox1.Text &= "Line two" & vbCrLf
How do I make the first line appear BOLD?



Feb 14 '06 #10

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

Similar topics

3
by: Alfredo Agosti | last post by:
Hi folks, I have an Access 2000 db with a memo field. Into the memo field I put text with bold attributes, URL etc etc What I need to to is converting the rich text contained into the memo...
6
by: Mark Miller | last post by:
I have a scheduled job that uses different XSL templates to transform XML and save it to disk. I am having problems with the code below. The problem shows up on both my development machine (Windows...
0
by: Ken | last post by:
Is there any way I can easily set some text to bold in a rich text box control. prime example a CHAT GUI, i would like to set the user name bold. is this possible by doing so in the message...
0
by: ray well | last post by:
hi, my app has two parallel rich text boxes containing the same content in 2 different languages. the lines parallel each other, line #3 in english contains the same content as line #3 in...
5
by: GY2 | last post by:
I want to step through the rows returned by my DataView, extract some values from some of its columns and append them as separate lines to the text of various rich textbox controls while possibly...
1
by: pooba53 | last post by:
I have a rich textbox control and a long string of characters that I will assign to it's .text property. How can I bold some characters and apply italics to others?
16
by: Neil | last post by:
I posted a few days ago that it seems to me that the Access 2007 rich text feature does not support: a) full text justification; b) programmatic manipulation. I was hoping that someone might...
5
by: =?Utf-8?B?SnVzdGluIFJvYmVydHM=?= | last post by:
Hi I have noticed that the RTB control hides all Linefeed characters in it's text properties. Unfortunately these LF characters are masked in the Length properties also. I need the LF...
2
by: tristanlbailey | last post by:
I been scouring the Internet for an answer to my problem, and a couple of times thought I had almost found the answer, but still to no avail. I'm tying to use the Rich Edit class (riched20.dll),...
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
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,...
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...
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
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,...
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.