Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
Bear with me if this seems like a basic question cos i'm quite new to c++.net. I've dynamically created an array of picture boxes at runtime, the number of which depends on what value the user enters. I've assigned each box an event handler for when the user clicks on that box. The prolem i'm having is that i can't access any of the properties of the picture box from the event handler. Can anyone help?!
Posted (edited)

void MyForm::InializeComponent(int x)

{

//All static form properties and components set here

....

 

PictureBox *Gallery[] = new PictureBox *[x];

for(int i =0; i<Gallery->Length; i++)

{

Gallery = new PictureBox;

Gallery->BorderStyle = BorderStyle::Fixed3D;

// more properties set here....

 

Gallery->Click += new EventHandler(this, pbox_Click);

}

}

 

void MyForm:: pbox_Click(Object *sender, EventArgs *e)

{

Gallery[2]->Size = Drawing::Size(100,100);

//other stuff

}

 

Thats the gist of it. I get an undeclared identifier "Gallery" in the debug window which occurs on the gallery[2]->Size.... line in the event handler. I thought the problem was that when i assign the event handler i'm using the this pointer instead of a pointer to gallery but i can't get it to accept Gallery[] or *Gallery[] or anything similar. I think i'm missing something obvious but the more i stare at it the more confused i get!

Edited by jedbartlet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...