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 to |
---|---|
Tab area of the Tab control, including clicks or drag actions on tabs |
The Tab control |
Tab page (but not the tab) |
The tab page (for embedded tab pages) or the user object (for independent tab pages) |
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.
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:
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:
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