帮助vb.net中的picturebox控件 [英] Help with picturebox control in vb.net
问题描述
所以,这是我的情况。我写了这段代码,我的表格中有两个图片框。现在,我使用带有计时器的两个图片框创建了一个动画。问题是我想写一个if else语句应该有点像这样 - 当我点击第一个图片框时,它说尝试另一个,我点击的图片框应该消失,计时器继续进行,同样的事情也发生在另一个图片框中。它只有当我点击两个图片框时才会停止计时器。我怎么能为pictureboxes写一个if-else语句。请帮帮我。
这个怎么样:
< pre lang =vb> 私有 Sub Timer1_Tick( ByVal sender As System。 Object , ByVal e As System.EventArgs)句柄 Timer1.Tick
< span class =code-keyword>如果 不 PictureBox1.Visible AndAlso 不 PictureBox2.Visible 然后
Timer1。停止
结束 如果
结束 Sub
我读你的问题的方式,你不能:你不能同时点击两个图片框,因为你只有一个鼠标指针,因此一个点击位置。
我认为你需要重新思考你的设计,并找到一种方法让用户做一些可能的事情! :笑:
So, this is my situation. I have written this code where i have two pictureboxes in my form. Now, i created an animation using the two pictureboxes with a timer. The problem is that i want to write a if else statement which should be somewhat like this - when i click on the first picturebox, it says "try the other one" and the picturebox i clicked should disappear and the timer keeps going on and the same thing happens with the other picturebox too. Its only when i click on both the pictureboxes, thats when the timer stops. How can i write such a if-else statement for pictureboxes. Please help me.
解决方案How about this:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick If Not PictureBox1.Visible AndAlso Not PictureBox2.Visible then Timer1.Stop End If End Sub
The way I read your question, you can't: you cannot "click on both pictureboxes" at the same time, as you only have the one mouse pointer, and thus the one "Click" position.
I think you need to rethink your design, and work out a way for the user to do things that are possible! :laugh:
这篇关于帮助vb.net中的picturebox控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!