Problem with ByValue Parameters
-
At start I have a picturebox generated by Runtime, image is already initialized. The name of the pbox is "picBoxDoubles_object1". Now I have an ArrayList and want add this picturebox.
public void MovePicToDest(PicBoxDoubles pbd) { ArrayList arr = new ArrayList(); arr.Add(pbd); arr.Clear(); <----------- }
If arr.Clear is executed, the picturebox disappears from the desktop. Is "pbd" not a parameter ByValue? So it seems, that the real object was added not a copy. How can I solve this one? -
At start I have a picturebox generated by Runtime, image is already initialized. The name of the pbox is "picBoxDoubles_object1". Now I have an ArrayList and want add this picturebox.
public void MovePicToDest(PicBoxDoubles pbd) { ArrayList arr = new ArrayList(); arr.Add(pbd); arr.Clear(); <----------- }
If arr.Clear is executed, the picturebox disappears from the desktop. Is "pbd" not a parameter ByValue? So it seems, that the real object was added not a copy. How can I solve this one?Change the method to accept PictureBox type. public void MovePicDest(PictureBox pb) { ArrayList arr = new ArrayList(); arr.Add(pb); //Now if ArrayList.Clear is called; it should clear the arraylist and not remove your object. arr.Clear(); }
-
Change the method to accept PictureBox type. public void MovePicDest(PictureBox pb) { ArrayList arr = new ArrayList(); arr.Add(pb); //Now if ArrayList.Clear is called; it should clear the arraylist and not remove your object. arr.Clear(); }
-
PicBoxDoubles has Inheritance to PictureBox, so if I am change the parameter it still doesn't work.
What is the reason behind adding the picturebox to the ArrayList?
-
What is the reason behind adding the picturebox to the ArrayList?
-
The application has two big Pictureboxes A and B. "A" has many child objects(PictureBoxes) and if you click on one of these, they are copied to "B". Actually they are transfered during this problem. It should stay in A and make a copy to B.
-
I made a new object of this class and copied each attribute. This works, but the inherited Picturebox has more than 80 new attributes. Not a real good solution. I need to know how to copy objects.