Results 1 to 3 of 3

Thread: problem in creating textbox at runtime

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    153

    problem in creating textbox at runtime

    hi to all,
    i am creating the textbox at runtime. the code is like that,


    int xpoint1 = 147
    int xpoint2 = 289
    int ypoint1 = 76
    int ypoint2 = 76
    int size1 = 102
    int size2 = 20;
    TextBox txtvalue11 = new TextBox();
    txtvalue11.Name = "value1" + intvar;
    txtvalue11.Size = new Size(size1, size2);
    txtvalue11.Location = new Point(xpoint1, ypoint1);
    txtvalue11.Visible = true;
    this.groupBox3.Controls.Add(txtvalue11);


    i need to access the neewly(runtime) created textbox. how can i access the textbox. i have tried one way, in that,i am storing the textbox name in the arraylist. the code is


    TextBox txt=(System.Windows.Forms.TextBox(arrlist[i].toString());

    its giving the error " Unable to convert string to textbox";

    how can i solve the problem, plz somebody help me to solve the problem.

    thank u.

    with thanks and regards
    mmary

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    Re: problem in creating textbox at runtime

    Remove the ".ToString()" call when you're retrieving the textbox from the arraylist:
    Code:
    TextBox txt = (TextBox) arrlist[i];

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: problem in creating textbox at runtime

    You shouldn't be storing the Name of the TextBox in this ArrayList. You should be storing the TextBox itself. Then you can do what axion_sa suggests to retrieve it.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width