Formatting Text on a textbox

H

HardySpicer

I have a list of commands in an array command_string() that I want to
display in a textbox.

I can get them all in one column easily enough like this

For i = 0 To command_string.Length - 1
TextBox1.Text += command_string(i) & vbCrLf
Next

But I want them in two or more collumns. How do I do this? Also, the
text when it appears in a column is "selected" text for some reason
(like in a word processor). Why is this?

Hardy
 
C

Cor Ligthert[MVP]

Hardy,

Why don't you use, as you want it in your style, a maskedtextbox, they have
made it for that reason

Cor
 
B

Branco

Cor Ligthert[MVP] wrote in an answer to HardySpicer:
Why don't you use, as you want it in your style, a maskedtextbox, they have
made it for that reason
"HardySpicer" <[email protected]> wrote in message
<snip>

Please, correct me if I'm wrong, but as far as I know the
MaskedTextBox doesn't support multi-line formatting.


Regards,

Branco
 
B

Branco

HardySpicer said:
I have a list of commands in an array command_string() that I want to
display in a textbox.

I can get them all in one column easily enough like this

For i = 0 To command_string.Length - 1
            TextBox1.Text += command_string(i) & vbCrLf
        Next

But I want them in two or more collumns. How do I do this?

If all strings are somewhat the same size, you could use a Tab (vbTab
or ControlChars.Tab) to separate the items by column:

<example>
'Cols contains the number of columns
Dim Cols As Integer = 3
Dim S As New System.Text.StringBuilder
For I As Integer = 0 To command_string.Length - 1
S.Append(command_string(i) _
& if (((I+1) Mod Cols) = 0, vbCrLf, vbTab))
Next
TextBox1.Text = S.ToString
Also, the
text when it appears in a column is "selected" text for some reason
(like in a word processor). Why is this?

Lol, sorry, have no idea, I couldn't reproduce it here. Can you be
more specific?

HTH.

Regards,

Branco
 
H

HardySpicer

If all strings are somewhat the same size, you could use a Tab (vbTab
or ControlChars.Tab) to separate the items by column:

  <example>
  'Cols contains the number of columns
  Dim Cols As Integer = 3
  Dim S As New System.Text.StringBuilder
  For I As Integer = 0 To command_string.Length - 1
    S.Append(command_string(i) _
      & if (((I+1) Mod Cols) = 0, vbCrLf, vbTab))
  Next
  TextBox1.Text = S.ToString


Lol, sorry, have no idea, I couldn't reproduce it here. Can you be
more specific?

HTH.

Regards,

Branco

Thanks. The text is highlighted for some reason.

Hardy
 
C

Cor Ligthert[MVP]

You are right I misunderstood your question.

But AFAIK there is no multiline multicolumn control standard in Net.

As you real want that, then you need a 3th party control

If the multiline is less needed, then you can use a datagridview

You can set than your data in a generic list and simply databind it to that
using the bindingsource.

Cor

Cor Ligthert[MVP] wrote in an answer to HardySpicer:
Why don't you use, as you want it in your style, a maskedtextbox, they
have
made it for that reason
"HardySpicer" <[email protected]> wrote in message
<snip>

Please, correct me if I'm wrong, but as far as I know the
MaskedTextBox doesn't support multi-line formatting.


Regards,

Branco
 

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

Top