2010-11-22 131 views

回答

5

您可以將一個圖片框中顯示的Image分配給另一個圖片框。如果您希望從原始圖片框中刪除圖像(以便它不會顯示兩次),您可以將其Image屬性設置爲null(或者,當然,您可以指定您選擇的任何其他圖像)。像這樣:

//Assign the image in one picture box to another picture box 
mySecondPicBox.Image = myFirstPicBox.Image; 

//Clear the image from the original picture box 
myFirstPicBox.Image = null; 


如果你想交換兩個圖片框顯示的圖像,你需要暫時存儲在一個變量的圖片對象之一。所以你可以使用非常類似的代碼,稍作修改:

//Temporarily store the picture currently displayed in the second picture box 
Image secondImage = mySecondPicBox.Image; 

//Assign the image from the first picture box to the second picture box 
mySecondPicBox.Image = myFirstPicBox.Image; 

//Assign the image from the second picture box to the first picture box 
myFirstPicBox.Image = secondImage;