Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Resizing Array (a question about TextBox)

Resizing Array (a question about TextBox)

Scheduled Pinned Locked Moved C#
questiondata-structures
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Cristoff
    wrote on last edited by
    #1

    The RichText and the TextBox controls have the property Lines that of type string[]. Any idea how the controls handle the resizing of the Array? I want to know because I want to use an Array, which will hold properties for each Line of the TextBox control. Or do you have any suggestion what should I do best?

    L J J 3 Replies Last reply
    0
    • C Cristoff

      The RichText and the TextBox controls have the property Lines that of type string[]. Any idea how the controls handle the resizing of the Array? I want to know because I want to use an Array, which will hold properties for each Line of the TextBox control. Or do you have any suggestion what should I do best?

      L Offline
      L Offline
      lmoelleb
      wrote on last edited by
      #2

      I seriously doubt these controls store the array - the property most likely convert to and from the "native" format when you call the get or set method. So the solution is to use a collection: List

      1 Reply Last reply
      0
      • C Cristoff

        The RichText and the TextBox controls have the property Lines that of type string[]. Any idea how the controls handle the resizing of the Array? I want to know because I want to use an Array, which will hold properties for each Line of the TextBox control. Or do you have any suggestion what should I do best?

        J Offline
        J Offline
        J4amieC
        wrote on last edited by
        #3

        You could store each of your lines in an ArrayList, which autosizes for you when you Add or Remove. As long as you only put strings in there, you can use 1 simple line when you want to assign the lines: string [] lines = (string[])myArrayList.ToArray(typeof(string)); Current blacklist svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour

        1 Reply Last reply
        0
        • C Cristoff

          The RichText and the TextBox controls have the property Lines that of type string[]. Any idea how the controls handle the resizing of the Array? I want to know because I want to use an Array, which will hold properties for each Line of the TextBox control. Or do you have any suggestion what should I do best?

          J Offline
          J Offline
          Judah Gabriel Himango
          wrote on last edited by
          #4

          the TextBox controls create a new string[] everytime you request the Lines property. It is not stored; it's generated on-the-fly. As a side note (not that it will help you here) but one can resize an array using the Array.Resize static method.

          Tech, life, family, faith: Give me a visit. I'm currently blogging about: Islamic Domination: Coming to a Jewish state near you! The apostle Paul, modernly speaking: Epistles of Paul Judah Himango

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups