I am busy with a ‘home made’ solitaire game just for fun but think however that I worked myself into a bit of a corner and was hoping for some advice perhaps.
In short instead dragging and dropping a card to a different location I click on the card to be moved (displayed in a picturebox) facing upwards and set the visiblity to false and add the cardvalue to an ArrayList(named picFaceUpToBeMoved).
I click on a second card and then of course based on certain conditions the card will be displayed just above the card I clicked now.I create an instance of the PictureBox control setting the size and location.
PictureBox picOneFaceUpA = new PictureBox();
picOneFaceUpA.Location = new Point(42, 202);
picOneFaceUpA.Width = 90;
picOneFaceUpA.Height = 120;
picOneFaceUpA.Image = Image.FromFile("../../Resources/" + picFaceUpToBeMoved[0] + ".png");
Controls.Add(picOneFaceUpA);
picOneFaceUpA.BringToFront();
The problem I have now is how to go about in moving this card as it doesn’t have an onClick event.
Sorry, a bit inexperienced and was hoping for advice on how to overcome this issue or how I could approach this game differently.
Try adding an event handler to
MouseClick.More documentation can be found here: http://msdn.microsoft.com/en-us/library/system.windows.forms.control.mouseclick.aspx
And have a look at all other events there are available, for dragging you could use
MouseDown,MouseMove,MouseUp, etc.A list of available events can be found here: http://msdn.microsoft.com/en-us/library/1dk48x94.aspx