Jump to content
  • Advertisement
Sign in to follow this  
Zmurf

Windows Forms, Event Applied to Group of Objects

This topic is 4863 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm making a sorta connect 4 game in a windows form to test out WinSock. And in this game i have 49 picture boxes that you can click to place your piece when it's your turn. Now, I'm far too lazy to set up the same event that runs the same checks for placing your piece on all 49 picture boxes so i tried to make the click event all point to the same event. Eg:
private: System::Void changePicBox_(System::Object *  sender, System::EventArgs *  e){
			 System::Windows::Forms::PictureBox * tempControl = (System::Windows::Forms::PictureBox *)(sender->ToString());
			 MessageBox::Show(tempControl->Name);
		 }

I was hoping this would work but I was pretty sure it wouldn't. And it didn't. What I was hoping it would do was return the System::Object as sender and i would be able to convert it to an instanc eof that object and edit it properties. This would save me alot of time. (The reson a message box pops up telling you the objects name is for debugging) Does anyone know how I can fix this so it works? It would be greatly appreciated. Thanks in advanced! BTW: I am programming in Visual Studio .Net 2003 (Visual C++)

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Woah there. sender->ToString()???
A PictureBox is NOT a string! :p

Remove the ToString() and it should work fine.

Share this post


Link to post
Share on other sites
Oh ok, I thought it would return the control's name and I would have to change it to a string, then convert it to a control. Now that I think about it that doesn't make any sence!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!