richTextBox with the style

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'd like to display a set of data in the following format in a richTextBox,
could anyone of you tell me how to do it?

data1 value1
data2 value2
....
datan valuen

where data1, data2, ...datan are supposed to be in bold font, and value1,
value2, ...
valuen are in non-bold font. All data is coming from a dataSet object.

Thanks for the help
 
Assembly file locked said:
I'd like to display a set of data in the following format in a
richTextBox,
could anyone of you tell me how to do it?

data1 value1
data2 value2
...
datan valuen

where data1, data2, ...datan are supposed to be in bold font, and value1,
value2, ...
valuen are in non-bold font. All data is coming from a dataSet object.

\\\
Dim dt As New DataTable
dt.Columns.AddRange( _
New DataColumn() { _
New DataColumn("Name"), _
New DataColumn("Location") _
} _
)
dt.Rows.Add(New Object() {"Peter", "Redmond"})
dt.Rows.Add(New Object() {"Frank", "Seattle"})
dt.Rows.Add(New Object() {"Sam", "Vienna"})
dt.Rows.Add(New Object() {"Bradley", "New Hampshire"})
dt.Rows.Add(New Object() {"Jonathan", "Tokyo"})
Dim ds As New DataSet
ds.Tables.Add(dt)
Dim BoldFont As Font = _
New Font(Me.RichTextBox1.Font, FontStyle.Bold)
Dim NormalFont As Font = Me.RichTextBox1.Font
With Me.RichTextBox1
.Text = ""
.SelectionTabs = New Integer() {100}
For Each Row As DataRow In ds.Tables(0).Rows
.SelectionFont = BoldFont
.AppendText(Row(0))
.SelectionFont = NormalFont
.AppendText( _
ControlChars.Tab & Row(1) & ControlChars.NewLine _
)
Next Row
End With
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top