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. How to create Control array?

How to create Control array?

Scheduled Pinned Locked Moved C#
tutorialdatabasedata-structuresquestionannouncement
2 Posts 2 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.
  • 1 Offline
    1 Offline
    12Code
    wrote on last edited by
    #1

    I wish to create quite a number of TextBox controls in a form. Is there anyway I can create a array of TextBox controls, so the controls can be updated by calling the array control with index. for example I can update all the TextBox Text by the following code: int i=0; foreach(TextBox txtBox in txtBoxes) { i++; txtBox.Text = "Control " + i; } where txtBoxes is a array of all the TextBox controls in the form.

    ;)*12Code

    A 1 Reply Last reply
    0
    • 1 12Code

      I wish to create quite a number of TextBox controls in a form. Is there anyway I can create a array of TextBox controls, so the controls can be updated by calling the array control with index. for example I can update all the TextBox Text by the following code: int i=0; foreach(TextBox txtBox in txtBoxes) { i++; txtBox.Text = "Control " + i; } where txtBoxes is a array of all the TextBox controls in the form.

      ;)*12Code

      A Offline
      A Offline
      a hamidy
      wrote on last edited by
      #2

      follow the steps.

      TextBox[] textBoxes=new TextBox[]{txt1,txt2,txt3,txt4};
      foreach(TextBox t in textBoxes)
      t.Text=string.Empty;

      where txt1,txt2,.. is the name of TextBoxes in Form.

      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