SelectionChanging event
The SelectionChanging event has different arguments
for different objects:
|
Object |
See |
|---|---|
|
Tab control |
|
|
TreeView control |
Syntax 1 For Tab controls
Description
Occurs when another tab is about to be selected.
Event ID
|
Event ID |
Objects |
|---|---|
|
pbm_tcnselchanging |
Tab |
Parameters
|
Argument |
Description |
|---|---|
|
oldindex |
Integer by value |
|
newindex |
Integer by value |
Return Values
Long. Return code choices (specify in
a RETURN statement):
-
0 Allow the
selection to change -
1 Prevent the selection from changing
Usage
Use the SelectionChanging event to prevent the selection from
changing or to do processing for the newly selected tab page before
it becomes visible. If CreateOnDemand is true and
this is the first time the tab page is selected, the controls on
the page do not exist yet, and you cannot refer to them in the event script.
Examples
When the user selects a tab, this code sizes the
DataWindow control on the tab page to match the size of another
DataWindow control. The resizing happens before the tab page becomes
visible. This example is from tab_uo in
the w_phone_dir window in
the PowerBuilder Examples:
|
1 |
u_tab_dirluo_Tab |
|
1 |
luo_Tab = This.Control[newindex] |
|
1 |
luo_Tab.dw_dir.Height = dw_list.Height |
|
1 |
luo_Tab.dw_dir.Width = dw_list.Width |
See Also
Syntax 2 For TreeView controls
Description
Occurs when the selection is about to change in the TreeView
control.
Event ID
|
Event ID |
Objects |
|---|---|
|
pbm_tvnselchanging |
TreeView |
Parameters
|
Argument |
Description |
|---|---|
|
oldhandle |
Long by value (the |
|
newhandle |
Long by value (the |
Return Values
Long. Return code choices (specify in
a RETURN statement):
-
0 Allow the
selection to change -
1 Prevent the selection from changing
Usage
The SelectionChanging event occurs before the SelectionChanged
event.
Examples
This example displays the status of changing TreeView
items in a SingleLineEdit:
|
1 |
TreeViewItem l_tvinew, l_tviold |
|
1 |
|
1 |
// Get TreeViewItem that was the old selection |
|
1 |
This.GetItem(oldhandle, l_tviold) |
|
1 |
|
1 |
// Get TreeViewItem that is currently selected |
|
1 |
This.GetItem(newhandle, l_tvinew) |
|
1 |
|
1 |
//Display the labels for the two items in display |
|
1 |
sle_status.Text = "Selection changed from " & |
|
1 |
   + String(l_tviold.Label) + " to " & |
|
1 |
   + String(l_tvinew.Label) |