Events
for the parts of the Tab control
With so many overlapping pieces in a Tab control, you need to know
where to code scripts for events.
|
To respond to actions in the |
Write a script for events belonging |
|---|---|
|
Tab area of the Tab control, including clicks or |
The Tab control |
|
Tab page (but not the tab) |
The tab page (for embedded tab pages) or the user |
|
Control on a tab page |
That control |
For example, if the user drags to a tab and you want to do
something to the tab page associated with the tab, you need to code the
DragDrop event for the Tab control, not the tab page.
Examples
This code in the DragDrop event of the tab_1 control selects the
tab page when the user drops something onto its tab. The index of the
tab that is the drop target is an argument for the DragDrop
event:
|
1 |
This.SelectTab( index ) |
The following code in the DragDrop event for the Tab control lets
the user drag DataWindow information to a tab and then inserts the
dragged information in a list on the tab page associated with the
tab.
A user object of type tabpage_listbox that contains a ListBox
control, lb_list, has been defined in the User Object painter. The Tab
control contains several independent tab pages of type
tabpage_listbox.
You can use the index argument for the DragDrop event to get a tab
page reference from the Tab control’s Control property array. The user
object reference lets the script access the controls on the tab
page.
The Parent pronoun in this script for the Tab control refers to
the window:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
long ll_row string ls_name tabpage_listbox luo_tabpage IF TypeOf(source) = DataWindow! THEN l_row = Parent.dw_2.GetRow() ls_name = Parent.dw_2.Object.lname.Primary[ll_row] // Get a reference from the Control property array luo_tabpage = This.Control[index] // Make the tab page the selected tab page This.SelectTab(index) // Insert the dragged information luo_tabpage.lb_list.InsertItem(ls_name, 0) END IF |
If the tab page has not been created
If the CreateOnDemand property for the Tab control is TRUE, the
Constructor events for a tab page and its controls are not triggered
until the tab page is selected. In the previous example, making the
tab page the selected tab page triggers the Constructor events. You
could also use the CreatePage function to trigger them:
|
1 2 |
IF luo_tabpage.PageCreated() = FALSE THEN & luo_tabpage.CreatePage() |