 |
我在一个Form 中放置了一SSTab控件,它含有多个页(tab),每页中含有多个textbox、combobox之类的控件。我想实现一自动功能,需要用用程序判断textbox属于sstab的哪一页(tab)。请问应如何处理? 我曾经尝试过查找textbox的属性,但其container和parent属性都无法判断。(Bush Lee)
|
| |
|
 |
Hiway的方案
以下办法不知是否满足这位朋友的要求?请指正。
Dim MyObj as Object
Dim TabID
Set Myobj=Text1.Container
TabID=MyObj.Tab
James Wayne的方案
First, I am sorry that I don't have a Chinese editor. That means I have to answer this in English.
The Left property of controls on the inactive tab of the sstab is set to itsself - 75000 so use the following function can get the tab number of the sstab:
Public Function TabNumber(Control As Control) As
Integer
Dim intCurrentTab As Integer
Dim intSearchTab As Integer
Control.Container.Visible = False
intCurrentTab = Control.Container.Tab
For intSearchTab = 0 To Control.Container.Tabs - 1
Control.Container.Tab = intSearchTab
If Control.Left > -100 Then
Control.Container.Tab = intCurrentTab
Control.Container.Visible = True
TabNumber = intSearchTab
Exit Function
End If
Next intSearchTab
Control.Container.Tab = intCurrentTab
Control.Container.Visible = True
TabNumber = -1
End Function
but the side effict this function will fire the click event of the sstab control. I believe that you can use the basic thinking of this function to do your automation.
engels的方案
在SSTAB中的第一个页面加控件1,第二个页面加控件2。
然后判断:
if 控件1.left>0 then
msgbox "第一个页面打开"
else
if 控件2.left>0 then
msgbox "第二个页面打开"
end if
end if
注:非激活的页面,其上的所有控件的left都小于零。
此问题由Hiway等回答。
附加关键字:编程, 源程序, programming, source code, Visual Basic, VB, 标准控件, screen, button, combo, checkbox, listbox。
|
| |
|
| |
|
| |
|
|