Home All Groups Group Topic Archive Search About

Formatting Text on a textbox

Author
11 Jun 2009 11:28 PM
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

Author
12 Jun 2009 9:13 AM
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

Show quoteHide quote
"HardySpicer" <gyansor***@gmail.com> wrote in message
news:da4fafc3-d8dc-4b13-a78a-2f11b80227bc@x31g2000prc.googlegroups.com...
>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
Author
12 Jun 2009 6:44 PM
Branco
Cor Ligthert[MVP] wrote in an answer to HardySpicer:
<snip>
> Why don't you use, as you want it in your style, a maskedtextbox, they have
> made it for that reason
<snip>
> "HardySpicer" <gyansor***@gmail.com> wrote in message
<snip>
> >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?
<snip>

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


Regards,

Branco
Author
13 Jun 2009 5:49 AM
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

"Branco" <branco.medei***@gmail.com> wrote in message
news:0e9dcb29-0b9d-48b8-b1a6-ab916644e51e@c20g2000prh.googlegroups.com...
Cor Ligthert[MVP] wrote in an answer to HardySpicer:
<snip>
> Why don't you use, as you want it in your style, a maskedtextbox, they
> have
> made it for that reason
<snip>
> "HardySpicer" <gyansor***@gmail.com> wrote in message
<snip>
> >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?
<snip>

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


Regards,

Branco
Author
12 Jun 2009 6:54 PM
Branco
HardySpicer wrote:
> 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
  </example>


> 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
Author
12 Jun 2009 8:31 PM
HardySpicer
On Jun 13, 6:54 am, Branco <branco.medei***@gmail.com> wrote:
Show quoteHide quote
> HardySpicer wrote:
> > 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
>   </example>
>
> > 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

Thanks. The text is highlighted for some reason.

Hardy