Thread: textButton array using Microsoft Visual Designer

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    1

    textButton array using Microsoft Visual Designer

    Hi,
    I built a form with Microsoft Viual C# tool with about 60 textBox on it.
    The tool is building the textBox named "texbox1, textBox2" etc.
    Because I have to many, I want use textBox array (ex: textBox[1], textBox[2]).
    I've been able to modify the source and can "build Solution" without error, but when I click on the "Form1.cs [Design]", I got this error
    "The code within the method 'InitializeComponent' is generated by the designer and should not be manually modified. Please remove any changes and try opening the designer again."
    AM I missing something here ? Is there a way using Microsoft Visual [The Designer] to change "textBox1" to "textBox[1]", or a way to change it from the source without this error message from the Designer ????

    I would really appreciate if someone can help me.

    Thanks

    Stephane

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Well, first you must never hand-modify the code generated by the designer. It won't be able to parse it back in.

    As for your original goal, read up on the System.Windows.Forms.ContainerControl class; I believe it should suit your needs.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    129
    Search right back for one of my threads, there's not many.

    Basically you create an array with the textbox names, then you reference these by doing something like:

    Code:
    ArrayList arrayName[] = new ArrayList();
    
    arrayName.Add(textBox1);
    arrayName.Add(textBox2);
    
    (textBox)arrayName[n].enabled = true; // probably close this in a for loop!
    He who asks is a fool for five minutes, but he who does not ask remains a fool forever.

    The fool wonders, the wise man asks. - Benjamin Disraeli

    There are no foolish questions and no man becomes a fool until he has stopped asking questions. Charles Steinmetz

  4. #4
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    If you're using .Net 2.0, you should almost never use ArrayList. Opt for the generic List instead.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  5. #5
    Registered User
    Join Date
    Jun 2003
    Posts
    129
    Old habits die hard, worked well for me
    He who asks is a fool for five minutes, but he who does not ask remains a fool forever.

    The fool wonders, the wise man asks. - Benjamin Disraeli

    There are no foolish questions and no man becomes a fool until he has stopped asking questions. Charles Steinmetz

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM
  2. question about .net to 6.0 change causing errors
    By jverkoey in forum C++ Programming
    Replies: 17
    Last Post: 03-23-2004, 10:45 AM
  3. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 04:49 AM
  4. errors in my class....
    By o0obruceleeo0o in forum C++ Programming
    Replies: 9
    Last Post: 04-14-2003, 03:22 AM
  5. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 05:27 AM