来自问题 [英] From Question
问题描述
小组,
对不起,我知道这可能已经被问到了很多时间,对不起还有
我的愚蠢(我是新手!)但是......
我有一个主窗体,上面有一个按钮。当用户点击按钮我
希望它打开Form2并关闭Form 1,但是对于我的生活,我可以看到
找到它的位置。
我有以下代码来调出表格
Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As
System.EventArgs)处理Button1.Click
Dim Form1 As New Form1()
Form1.Show()
结束子
我也试过
Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As
System.EventArgs)处理Button1.Click
Dim Form1 As New Form1()
Form1.Show()
Me.Close
结束子
但这会打开Form2并再次直接关闭它。
我我也尝试过Form1.ShowDialog()但是dosn似乎对它们有帮助吗?
任何bosy对链接都有任何建议吗?
Ta
Si
*"!新手" < S _ ************ @ yahoo.co.uk> scripsit:对不起,我知道这可能已经被问了很多时间,也很抱歉
我的愚蠢(我是新手!)但是......
我有一个主窗体,上面有一个按钮。当用户点击按钮时我想要打开Form2并关闭Form 1但是为了我的生活,我可以找到它的位置。
< http://www.google.com/groups?selm = u%23xQOutWDHA.2100%40TK2MSFTNGP11.phx。 gbl>
-
Herfried K. Wagner [MVP]
< http://www.mvps.org / dotnet>
谢谢你的帮助,
我试过了,但它没有用,这里去了 - 表格1上有2个表格(Form1&
表格2)。我在Button1的代码中有一个按钮(Button1)如下
Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As
System.EventArgs)处理Button1.Click
Dim f2 as Form2
f2 = New Form2()
f2.Show()
Me.Close()
End Sub
>
当我点击按钮时,Form2加载然后关闭它自己
直接离开,如果我拿出Me.Close它保持打开但是Form1
如果在加载Form2时如何让Form1关闭?
除了Button1_Click之外我还需要其他代码吗?
Ta
Si
" Herfried K. Wagner [MVP] QUOT; <喜*************** @ gmx.at>在消息中写道
news:br ************* @ ID-208219.news.uni-berlin.de ...*新手! < S _ ************ @ yahoo.co.uk> scripsit:对不起,我知道这可能已经被问了很多时间,对不起还有
因为我的愚蠢(我是新手!)但是......
我有一个主窗体,上面有一个按钮。当用户点击Button
时,我希望它打开Form2并关闭Form 1,但是对于我的生活,我可以找到它的位置。
< http: //www.google.com/groups?selm=u%...TNGP11.phx.gbl
- Herfried K. Wagner [MVP] >< http://www.mvps.org/dotnet>
*" Newbie!" < S _ ************ @ yahoo.co.uk> scripsit:我试过了,但它没有用,这里去了 - 我在Form 1上有2个Form(Form1&
表2)。我有一个Button( Button1的代码中的Button1)如下:
Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As
System.EventArgs)处理Button1.Click
Dim f2 as Form2
f2 =新Form2()
f2.Show()
Me.Close()
End Sub
当我点击按钮,Form2加载然后关闭它自己
直接走开,如果我取出Me.Close它保持打开但Form1也是如此
当Form2是Form2时如何让Form1关闭我还需要除Button1_Click以外的其他代码吗?
不,你的代码是正确的,但你的应用程序正在失去它的消息
在关闭表格时抽水。例如,您必须使用我在上一篇文章中引用的代码
。什么不起作用?你确定
项目的启动对象设置为''Sub Main''(在项目中
属性)?
-
Herfried K. Wagner [MVP]
< http://www.mvps.org/dotnet>
Hi Group,
Sorry I know this has probably been asked loads of time, and sorry also for
my stupidity (Im a Newbie!) but ......
I have a Main Form with a button on it. When a user Clicks on the Button I
want it to Open Form2 and Close Form one but for the life of me I carn`t
find out where to do it.
I have the following Code to bring up a Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim Form1 As New Form1()
Form1.Show()
End Sub
I`ve Also Tryed
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim Form1 As New Form1()
Form1.Show()
Me.Close
End Sub
But this opens up Form2 and close`s it again straight Away.
I`ve also tryed Form1.ShowDialog() but that dosn`t seem to help either?
Any bosy got any suggestions on Links?
Ta
Si
* "Newbie!" <s_************@yahoo.co.uk> scripsit:Sorry I know this has probably been asked loads of time, and sorry also for
my stupidity (Im a Newbie!) but ......
I have a Main Form with a button on it. When a user Clicks on the Button I
want it to Open Form2 and Close Form one but for the life of me I carn`t
find out where to do it.
<http://www.google.com/groups?selm=u%23xQOutWDHA.2100%40TK2MSFTNGP11.phx. gbl>
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Hi thanks for you help,
I`ve tryed that but it dosn`t work, here goes - I have a 2 Forms (Form1 &
Form 2) on Form 1. I have a Button (Button1) in Button1`s code as follows
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim f2 as Form2
f2 = New Form2()
f2.Show()
Me.Close()
End Sub
How ever when i Click on the Button, Form2 loads then closes it`s self
stright away, If i take out the Me.Close it stays open but so does Form1
How do I get Form1 to Close When Form2 is loaded?
Do I need any Code else where other than Button1_Click?
Ta
Si
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:br*************@ID-208219.news.uni-berlin.de...* "Newbie!" <s_************@yahoo.co.uk> scripsit:Sorry I know this has probably been asked loads of time, and sorry also for my stupidity (Im a Newbie!) but ......
I have a Main Form with a button on it. When a user Clicks on the Button I want it to Open Form2 and Close Form one but for the life of me I carn`t
find out where to do it.
<http://www.google.com/groups?selm=u%...TNGP11.phx.gbl
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
* "Newbie!" <s_************@yahoo.co.uk> scripsit:I`ve tryed that but it dosn`t work, here goes - I have a 2 Forms (Form1 &
Form 2) on Form 1. I have a Button (Button1) in Button1`s code as follows
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim f2 as Form2
f2 = New Form2()
f2.Show()
Me.Close()
End Sub
How ever when i Click on the Button, Form2 loads then closes it`s self
stright away, If i take out the Me.Close it stays open but so does Form1
How do I get Form1 to Close When Form2 is loaded?
Do I need any Code else where other than Button1_Click?
No, your code is correct, but your application is loosing its message
pump when closing the form. You will have to use, for example, the code
I referenced in my last post. What doesn''t work? Are you sure the
project''s startup object is set to ''Sub Main'' (in the project
properties)?
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
这篇关于来自问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!