Array of pointers to Controls(Buttons, GoupBox)

This is a discussion on Array of pointers to Controls(Buttons, GoupBox) within the C# Programming forums, part of the General Programming Boards category; Hi. I am using Visual Studio .NET to develop a windows application. In my program, I have a set of ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    2

    Question Array of pointers to Controls(Buttons, GoupBox)

    Hi.

    I am using Visual Studio .NET to develop a windows application.

    In my program, I have a set of similar controls(group box) which I would like to be set visible or invisible depending on the current state of the program.

    The positioning are handled by the form design and I have named the group boxes groupbox1, groupbox2, groupbox3, ...

    I would like to address the group boxes by their numerical position and so I wish to have an array of pointer such that I can:

    Code:
      for(int x=0; x<12; x++)
        groupbox[x].Visible = false;
    groupbox[findactivegroup()].Visible = true;
    So I thought of something like:

    Code:
      System.Windows.Forms.GroupBox [] *groupbox = *System.Windows.Forms.GroupBox[12];
      groupbox[0] = groupbox1;
      groupbox[1] = groupbox2;
      //....
    But there is syntax errors in the declaration.

    Could someone kindly enlighten me on this problem.

    Thank in advanced.
    Last edited by edinnide; 04-04-2007 at 03:49 AM.

  2. #2
    Registered User
    Join Date
    Apr 2007
    Posts
    2
    Found a solution.

    GroupBox groupbox[] = new groupbox[12];
    groupbox[0] = groupbox0;
    groupbox[1] = groupbox1;
    ...

    Thanks for reading.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Returning an Array of Pointers to Objects
    By randomalias in forum C++ Programming
    Replies: 4
    Last Post: 04-29-2006, 02:45 PM
  2. Searching an array with pointers
    By pxleyes in forum C Programming
    Replies: 16
    Last Post: 03-23-2004, 04:07 PM
  3. Passing pointers between functions
    By heygirls_uk in forum C Programming
    Replies: 5
    Last Post: 01-09-2004, 05:58 PM
  4. array of pointers to struct array
    By eth0 in forum C++ Programming
    Replies: 1
    Last Post: 01-08-2004, 05:43 PM
  5. array of pointers to structs
    By stumon in forum C Programming
    Replies: 7
    Last Post: 03-24-2003, 06:13 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21