473,498 Members | 1,793 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Make font Bold

I have just done an application that will allow you to insert XML into
a text box then do an xpath query to return the values against the
node. I am just a beginner so for me this is really cool but I want to
be able to get the nodes that returned information to be highlighted.
This is an example of my code at current:
Imports System.Xml

Public Class Form1
Dim used As Boolean
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim xmlstring As String = TextBox1.Text
'"<root><item>Trevor</item><item>Niemack</item><item>27 years
old</item><item>Married</item><item>Employed</item></root>"
Dim doc As New XmlDocument
doc.LoadXml(xmlstring)
Dim node As XmlNode

If used = True Then
used = False
End If
For Each node In doc.SelectNodes(TextBox3.Text)
ListBox1.Items.Add(node.InnerText)
used = True
Next

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
ListBox1.Items.Clear()
used = False
End Sub
End Class

Apr 24 '06 #1
6 1404
Hi Trevor,

You'll need to use a RichTextBox control if you want to show the
returned nodes in Bold. A simple TextBox won't do. You can drag it onto
your form from the Toolbox.

HTH,

Regards,

Cerebrus.

Apr 24 '06 #2
Thank you for the suggestion but now that I have inserted the
richtextbox I still am not sure of how to only bold selected nodes.

Apr 24 '06 #3
I'm sorry, I assumed you would have worked out that logic... Never
mind, here is one possible way :

1. You'll have to search for that particular word in the Text of the
RichTextBox(RTB), using the IndexOf method.
When you do find it, store the index position :

Dim idx as integer = RTB.Text.IndexOf(wordToFind, 0)

2. Select that particular word.

RTB.Select(idx, wordToFind.Length)

3. Make changes to it's Font :

RTB.SelectionFont = New Font(RTB.Font, FontStyle.Underline)

I guess that should do it. I've typed it here itself, so please watch
for syntax.

Regards,

Cerebrus.

Apr 24 '06 #4
Hi have a look at the SelectionFont property of the richtextbox that should
do what you want

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

<tr************@za.syspro.com> schreef in bericht
news:11*********************@t31g2000cwb.googlegro ups.com...
Thank you for the suggestion but now that I have inserted the
richtextbox I still am not sure of how to only bold selected nodes.

Apr 24 '06 #5
I can now see that my post was a bit late and Cerebrus already answered, but
that's because I forget to press F5 before posting :-)

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"Cerebrus" <zo*****@sify.com> schreef in bericht
news:11**********************@e56g2000cwe.googlegr oups.com...
I'm sorry, I assumed you would have worked out that logic... Never
mind, here is one possible way :

1. You'll have to search for that particular word in the Text of the
RichTextBox(RTB), using the IndexOf method.
When you do find it, store the index position :

Dim idx as integer = RTB.Text.IndexOf(wordToFind, 0)

2. Select that particular word.

RTB.Select(idx, wordToFind.Length)

3. Make changes to it's Font :

RTB.SelectionFont = New Font(RTB.Font, FontStyle.Underline)

I guess that should do it. I've typed it here itself, so please watch
for syntax.

Regards,

Cerebrus.

Apr 24 '06 #6
Lol, Peter... Happens to me all the time...

Regards,

Cerebrus.

Apr 24 '06 #7

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

Similar topics

1
4298
by: ajay | last post by:
I have following code for a slide menu but i twiked it to work for a single level menu. Open it in a Browser to get a clear picture. I have 2 Qs 1) How to make first entry as non-link. i.e i...
6
16091
by: Radith Silva | last post by:
I have the following code: Private Sub Bold(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuFileBold.Click If mnuFileBold.Checked = True Then mnuFileBold.Checked = False...
7
2924
by: Sakharam Phapale | last post by:
Hi All, How to preserve the old font properties while changing new one? I posted same question 2 months back, but I had very small time then. eg. "Shopping for" is a text in RichTextBox and...
5
1987
by: Novice Computer User | last post by:
Hi. Can somebody PLEASE help. Here is a .php script. Right now, the minimum amount of time (i.e. duration) allowed is 1 month. However, I want to be able to reduce the minimum amount of time to...
9
54339
by: Jason | last post by:
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?
1
2707
by: Henry Jones | last post by:
I found some code to change the font on a button to bold: private void btnBold_Click(object sender, System.EventArgs e) { btnCalculate.Font = new Font(btnCalculate.Font, ...
0
3560
by: benfly08 | last post by:
Hi, guys. I'm developing a web application for Sales Department people in my company. I used my 1024X768 resolution and "Medium" IE text size to test my Layout and it worked fine. However, some...
2
19622
by: Ben | last post by:
Hi I am having problems making a single node's Font Bold. objUserTree.Nodes.Item(i) I am looping though the items but with every property I try it fails. Thanks
8
45211
by: Ronald S. Cook | last post by:
How do I make a label bold at runtime (i.e. in code)? Thanks, Ron
8
30965
by: Alexey Smirnov | last post by:
How to make bold part of the text in a Windows.Forms.Label? Thank you.
0
7004
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7208
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
5464
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,...
1
4915
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...
0
4593
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3095
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...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1423
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
292
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...

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.