如何从其他表单获取信息...... [英] How to get info from another form...
问题描述
让我们说你打开包含TabControl1的Form1
TabControl1上有几个标签
现在你打开一个新的Form2包含用户控件
如何在
Form2中的用户控件中确定Form1中的Selected选项卡?
希望这很清楚......
谢谢!
5月25日,上午10:45,Rob < r ... @ yahoo.comwrote:
让我们说你打开包含TabControl1的Form1
TabControl1上有几个选项卡
现在你打开一个包含用户控件的新Form2
如何确定Form1中的Selected选项卡来自用户控件
Form2?
希望这个足够清楚...
谢谢!
IMO正确的方法是通过Form1中的属性
公开所选标签。
''输入消息
公共类Form1
Public Property SelectedTab As TabPage
获取
返回Me.TabControl1.SelectedTab
结束获取
设置(ByVal值为TabPage)
Me.TabControl1.SelectedTab = TabPage < br $>
结束集
结束物业
结束班
公共类Form2
Public Sub MyMethod()
Dim f As New Form1()
f.Show()
Dim tp As TabPage = f.SelectedTab
MessageBox.Show(tp.Name)
End Sub
End Class
谢谢,
Seth Rowe
谢谢Seth,
但我在Set语句中收到错误...
> Me.TabControl1.SelectedTab = TabPage
它说TabPag是一种类型,不能用作表达式
>
Rob
" rowe_newsgroups" < ro ******** @ yahoo.com在留言中写道
新闻:11 ********************** @ q66g2000hsg.googlegr oups.com ...
5月25日上午10:45,Rob < r ... @ yahoo.comwrote:
>让我们说你打开包含TabControl1的Form1
TabControl1上的几个选项卡
现在打开一个包含用户控件的新Form2
如何从Form2中的用户控件确定Form1中的Selected选项卡?
希望这很清楚......
谢谢!
IMO正确的方法是通过Form1中的物业公开所选标签
。
''输入消息
公共类Form1
Public Property SelectedTab As TabPage
获取
返回Me.TabControl1.SelectedTab
结束获取
设置(ByVal值为TabPage)
Me.TabControl1.SelectedTab = TabPage < br $>
结束集
结束物业
结束班
公共类Form2
Public Sub MyMethod()
Dim f As New Form1()
f.Show()
Dim tp As TabPage = f.SelectedTab
MessageBox.Show(tp.Name)
End Sub
End Class
谢谢,
Seth Rowe
嗯...
我的TabPage是动态添加的(w我没有陈述)...所以问题
可能就在我的最后。
" Rob" < ro *** @ yahoo.com写了留言
新闻:P8 *************************** ***@comcast.com。 ..
谢谢Seth,
但我在Set语句中收到错误...
>> Me.TabControl1.SelectedTab = TabPage
它说TabPag是一种类型,不能用作表达式
>
Rob
" rowe_newsgroups" < ro ******** @ yahoo.com在留言中写道
新闻:11 ********************** @ q66g2000hsg.googlegr oups.com ...
> 5月25日上午10点45分,抢劫 < r ... @ yahoo.comwrote:
>>让我们说你打开包含TabControl1的Form1
TabControl1上有几个选项卡
现在你打开一个包含用户控件的新Form2
如何从用户控件中确定Form1中的Selected选项卡> Form2?
希望这很清楚......
谢谢!
IMO正确的方法是通过Form1中的属性公开所选标签。
''输入消息
公共类Form1
Public Property SelectedTab As TabPage
获取
返回Me.TabControl1.SelectedTab
结束获取
设置(ByVal值为TabPage)
Me.TabControl1.SelectedTab = TabPage
结束集
结束财产
结束课
公共类Form2
Public Sub MyMethod()
Dim f As New Form1()
f.Show()
Dim tp As TabPage = f.SelectedTab
MessageBox.Show(tp.Name)<结束语
结束课
谢谢,
Seth Rowe
Let''s say you open Form1 that contains TabControl1
There are several tabs on TabControl1
Now you open a new Form2 that contains a User Control
How can you determine the Selected tab in Form1 from the User Control in
Form2 ?
Hope this is clear enough...
Thanks !
On May 25, 10:45 am, "Rob" <r...@yahoo.comwrote:Let''s say you open Form1 that contains TabControl1
There are several tabs on TabControl1
Now you open a new Form2 that contains a User Control
How can you determine the Selected tab in Form1 from the User Control in
Form2 ?
Hope this is clear enough...
Thanks !IMO the proper way would be to expose the selected tab via a property
in Form1.
'' Typed in message
Public Class Form1
Public Property SelectedTab As TabPage
Get
Return Me.TabControl1.SelectedTab
End Get
Set (ByVal value As TabPage)
Me.TabControl1.SelectedTab = TabPage
End Set
End Property
End Class
Public Class Form2
Public Sub MyMethod()
Dim f As New Form1()
f.Show()
Dim tp As TabPage = f.SelectedTab
MessageBox.Show(tp.Name)
End Sub
End Class
Thanks,
Seth Rowe
Thanks Seth,
But I am getting an error in in the Set statement...
> Me.TabControl1.SelectedTab = TabPage
It says "TabPag is a type and cannot be used as an expression"
Rob
"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11**********************@q66g2000hsg.googlegr oups.com...On May 25, 10:45 am, "Rob" <r...@yahoo.comwrote:>Let''s say you open Form1 that contains TabControl1
There are several tabs on TabControl1
Now you open a new Form2 that contains a User Control
How can you determine the Selected tab in Form1 from the User Control in
Form2 ?
Hope this is clear enough...
Thanks !
IMO the proper way would be to expose the selected tab via a property
in Form1.
'' Typed in message
Public Class Form1
Public Property SelectedTab As TabPage
Get
Return Me.TabControl1.SelectedTab
End Get
Set (ByVal value As TabPage)
Me.TabControl1.SelectedTab = TabPage
End Set
End Property
End Class
Public Class Form2
Public Sub MyMethod()
Dim f As New Form1()
f.Show()
Dim tp As TabPage = f.SelectedTab
MessageBox.Show(tp.Name)
End Sub
End Class
Thanks,
Seth Rowe
Hmmm...
My TabPage was dynamically added (which I did not state)...so the problem
is probably on my end.
"Rob" <ro***@yahoo.comwrote in message
news:P8******************************@comcast.com. ..Thanks Seth,
But I am getting an error in in the Set statement...
>> Me.TabControl1.SelectedTab = TabPage
It says "TabPag is a type and cannot be used as an expression"
Rob
"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11**********************@q66g2000hsg.googlegr oups.com...>On May 25, 10:45 am, "Rob" <r...@yahoo.comwrote:>>Let''s say you open Form1 that contains TabControl1
There are several tabs on TabControl1
Now you open a new Form2 that contains a User Control
How can you determine the Selected tab in Form1 from the User Control in
Form2 ?
Hope this is clear enough...
Thanks !
IMO the proper way would be to expose the selected tab via a property
in Form1.
'' Typed in message
Public Class Form1
Public Property SelectedTab As TabPage
Get
Return Me.TabControl1.SelectedTab
End Get
Set (ByVal value As TabPage)
Me.TabControl1.SelectedTab = TabPage
End Set
End Property
End Class
Public Class Form2
Public Sub MyMethod()
Dim f As New Form1()
f.Show()
Dim tp As TabPage = f.SelectedTab
MessageBox.Show(tp.Name)
End Sub
End Class
Thanks,
Seth Rowe
这篇关于如何从其他表单获取信息......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!