List Box question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Patrick De Ridder

    #1

    List Box question

    Using a list box to display a text file, I am having to adjust the
    length of the lines to fit the list box, (1) is there a way around
    this? (2) Can one use rtf files with a list box, does that have coding
    consequences when using the list box, if so which?
    Many thanks.
    --
    Regards,
    Patrick.
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: List Box question

    Patrick,

    Are you sure you are using a list box and not a textbox? The two have
    very different functionality.

    Why do you have to adjust the length of the lines to fit the textbox?
    The textbox should wrap around the lines automatically.

    If you use RTF files, then you will have to use a RichTextBox, which has
    the same base as the TextBox class, but with more functionality.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - nick(dot)paldin o=at=exisconsul ting<dot>com

    "Patrick De Ridder" <000@000.00> wrote in message
    news:h21dovsqh0 1pbc71kq5h0q3gd pkgd8p4ik@4ax.c om...[color=blue]
    > Using a list box to display a text file, I am having to adjust the
    > length of the lines to fit the list box, (1) is there a way around
    > this? (2) Can one use rtf files with a list box, does that have coding
    > consequences when using the list box, if so which?
    > Many thanks.
    > --
    > Regards,
    > Patrick.[/color]


    Comment

    • Patrick De Ridder

      #3
      Re: List Box question

      On Fri, 10 Oct 2003 10:17:10 -0400, "Nicholas Paldino [.NET/C# MVP]"
      <nicholas.paldi no@exisconsulti ng.com> wrote:
      [color=blue]
      >Patrick,
      >
      > Are you sure you are using a list box and not a textbox? The two have
      >very different functionality.
      >
      > Why do you have to adjust the length of the lines to fit the textbox?
      >The textbox should wrap around the lines automatically.
      >
      > If you use RTF files, then you will have to use a RichTextBox, which has
      >the same base as the TextBox class, but with more functionality.
      >
      > Hope this helps.[/color]

      I am using a list box because a text box takes only one line and I
      have many lines to display. I am doing it like so:

      for(int i = 0; i<k;i++)
      {
      show[i]=" "+strR2.ReadLin e();
      }
      listBox1.DataSo urce = show;

      The lines that overrun the width are not wrapped. How should I do this
      better? And in the case of a rich text box: how do I bind many lines
      of rich text from a file to a rich text box?

      Many thanks.
      --
      Regards,
      Patrick.

      Comment

      • Glen Jones

        #4
        Re: List Box question

        Patrick,

        This should not matter if your working with a WebForm or a WinForm.
        What it sounds like you need to do is use a Textbox.

        Set the Textbox property Multiline to true. And WordWrap to you needs.
        Then resize the Textbox.

        You can load a file by just setting the TextBox.Text property.
        But if you were using the Listbox because you wanted to know what line
        the user had selected then when loading the file split your string on
        "\r\n" then assign the string array to the Lines property.

        Also as another tip. To speed up the load, add all the file lines into
        a System.Text.Str ingBuilder object first. Then assign the
        StringBuilder.T oString() results to the TextBox.Text

        Hope this helps.

        Glen Jones MCSD
        NewData
        [color=blue]
        > I am using a list box because a text box takes only one line and I
        > have many lines to display. I am doing it like so:
        >
        > for(int i = 0; i<k;i++)
        > {
        > show[i]=" "+strR2.ReadLin e();
        > }
        > listBox1.DataSo urce = show;
        >
        > The lines that overrun the width are not wrapped. How should I do this
        > better? And in the case of a rich text box: how do I bind many lines
        > of rich text from a file to a rich text box?
        >
        > Many thanks.[/color]

        Comment

        • Patrick De Ridder

          #5
          Re: List Box question

          On 11 Oct 2003 04:51:56 -0700, glen_jones@hotm ail.com (Glen Jones)
          wrote:
          [color=blue]
          >Patrick,
          >
          >This should not matter if your working with a WebForm or a WinForm.
          >What it sounds like you need to do is use a Textbox.
          >
          >Set the Textbox property Multiline to true. And WordWrap to you needs.
          >Then resize the Textbox.
          >
          >You can load a file by just setting the TextBox.Text property.
          >But if you were using the Listbox because you wanted to know what line
          >the user had selected then when loading the file split your string on
          >"\r\n" then assign the string array to the Lines property.
          >
          >Also as another tip. To speed up the load, add all the file lines into
          >a System.Text.Str ingBuilder object first. Then assign the
          >StringBuilder. ToString() results to the TextBox.Text
          >
          >Hope this helps.
          >
          >Glen Jones MCSD
          >NewData
          >[/color]

          One you have displayed something in a textBox, how do you block the
          user from making changes to the text?
          --
          Regards,
          Patrick.

          Comment

          • Patrick De Ridder

            #6
            Re: List Box question

            On Sat, 11 Oct 2003 19:14:33 +0200, Patrick De Ridder <000@000.00>
            wrote:[color=blue]
            >
            >One you have displayed something in a textBox, how do you block the
            >user from making changes to the text?[/color]

            I cracked that one.

            Re textBoxes:

            I am left with this question: Is it possible to have a margin on the
            left hand side, or on both sides, so the text doesn't come right up to
            the side(s), which doesn't look so good.

            --
            Regards,
            Patrick.

            Comment

            Working...