vb.net Visual Basic 2010 清除图片框

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13281935/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 11:04:11  来源:igfitidea点击:

Visual Basic 2010 Clearing a Picture Box

vb.netvisual-studio-2010

提问by HashHazard

Im trying to build a simple poker game in visual basic studio 2010. When I click btnShuffle I assign the five image place holders the default backside of the card

我试图在 Visual Basic Studio 2010 中构建一个简单的扑克游戏。当我单击 btnShuffle 时,我将五个图像占位符指定为卡片的默认背面

btnShuffle_onClick......

    picFlop1.Image = My.Resources.BlankCard    //saved in my resources folder
    picFlop2.Image = My.Resources.BlankCard    //and so on and so on...

end sub

and then in my btnDeal cards I have tried every version of picFlop1.Dispose(), picFlop1.Image = Nothing... etc that I can find and nothing seems to erase the blank image.. I've tried skipping the clear step and just writing the actual face card overtop of the blank card, but it doesn't seem to show threw the initial blank card.. any help would be great..

然后在我的 btnDeal 卡中,我尝试了所有版本的 picFlop1.Dispose()、picFlop1.Image = Nothing... 等等,我可以找到并且似乎没有任何东西可以擦除空白图像.. 我试过跳过清除步骤和只是将实际的人脸卡写在空白卡的上面,但它似乎没有显示抛出了最初的空白卡..任何帮助都会很棒..

btnDeal_onClick...

   //find first five cards on deck and assign them by overwrite/delete blank card

   picflop1.Image = My.Resource.SomeCard  //Does Not Work
   picFlop1.Image.Dispose()     //Does Not Work
   picFlop1.Image = Nothing     //Does Not Work

end sub

UPDATE

更新

I am assigning these blank cards... not in the shuffle function but in the timer1 interval function.. could that have anything to do with it? The methods listed above work in a btnReset_onClick

我正在分配这些空白卡......不是在随机播放功能中,而是在 timer1 间隔功能中..这与它有什么关系吗?上面列出的方法在 btnReset_onClick 中工作

_Matt

_马特

采纳答案by HashHazard

Good call on looking closer at the timer @LarsTech..

很好地呼吁仔细观察计时器@LarsTech ..

Apparently if you don't stop the timer, it will continuously kick out the code to display the backs of the cards.. all the other code was functioning fine, just couldn't see it bc of the timer... Thanks guys.. as always.. your the best!

显然,如果你不停止计时器,它会不断踢出代码以显示卡片的背面..所有其他代码都运行良好,只是在计时器之前看不到它......谢谢大家。 . 一如既往.. 你是最好的!

回答by Derek Tomes

How about?

怎么样?

PictureBox1.Image = New Image

回答by BrainStorm.exe

Assuming that picFlip is a PictureBox, have you tried Invalidate() and then Update() after setting the new image?

假设picFlip是一个PictureBox,你有没有在设置新图像后尝试过Invalidate()和Update()?

回答by Daniel Abou Chleih

You have to

你必须

     PictureBox.Image = null

After that you can set a new image

之后,您可以设置新图像