SelectionChanged event
The SelectionChanged event has different arguments
for different objects:
|
Object |
See |
|---|---|
|
DropDownListBox, DropDownPictureListBox, |
|
|
Tab control |
|
|
TreeView control |
Syntax 1 For Listboxes
Description
Occurs when an item is selected in the control.
Event ID
|
Event ID |
Objects |
|---|---|
|
pbm_cbnselchange |
DropDownListBox, DropDownPictureListBox |
|
pbm_lbnselchange |
ListBox, PictureListBox |
Parameters
|
Argument |
Description |
|---|---|
|
index |
Integer by value |
Return Values
Long. Return code choices (specify in
a RETURN statement):
-
0 Continue
processing
Usage
For DropDownListBoxes, the SelectionChanged event applies
to selections in the drop-down portion of the control, not the edit
box.
The SelectionChanged event occurs when the user clicks on
any item in the list, even if it is the currently selected item.
When the user makes a selection using the mouse, the Clicked (and
if applicable the DoubleClicked event) occurs after the SelectionChanged
event.
Examples
This example is for the lb_value ListBox
in the window w_graph_sheet_with_list in
the PowerBuilder Examples application. When the user chooses values,
they are graphed as series in the graph gr_1.
The MultiSelect property for the ListBox is set to true,
so index has no effect. The script checks all
the items to see if they are selected:
|
1 |
integer itemcount,i,r |
|
1 |
string ls_colname |
|
1 |
|
1 |
gr_1.SetRedraw(FALSE) |
|
1 |
|
1 |
// Clear out categories, series and data from graph |
|
1 |
gr_1.Reset(All!) |
|
1 |
|
1 |
// Loop through all selected values and |
|
1 |
// create as many series as the user specified |
|
1 |
FOR i = 1 to lb_value.TotalItems() |
|
1 |
   IF lb_value.State(i) = 1 THEN |
|
1 |
      ls_colname = lb_value.Text(i) |
|
1 |
|
1 |
      // Call window function to set up the graph |
|
1 |
      wf_set_a_series(ls_colname, ls_colname, & |
|
1 |
      lb_category.text(1)) |
|
1 |
   END IF |
|
1 |
NEXT |
|
1 |
gr_1.SetRedraw(TRUE) |
See Also
Syntax 2 For Tab controls
Description
Occurs when a tab is selected.
Event ID
|
Event ID |
Objects |
|---|---|
|
pbm_tcnselchanged |
Tab |
Parameters
|
Argument |
Description |
|---|---|
|
oldindex |
Integer by value |
|
newindex |
Integer by value |
Return Values
Long. Return code choices (specify in
a RETURN statement):
-
0 Continue
processing
Usage
The SelectionChanged event occurs when the Tab control is
created and the initial selection is set.
See Also
Syntax 3 For TreeView controls
Description
Occurs when the item is selected in a TreeView control.
Event ID
|
Event ID |
Objects |
|---|---|
|
pbm_tvnselchanged |
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 Continue
processing
Usage
The SelectionChanged event occurs after the SelectionChanging
event.
Examples
This example tracks items in the SelectionChanged
event:
|
1 |
TreeViewIteml_tvinew, l_tviold |
|
1 |
|
1 |
// get the treeview item that was the old selection |
|
1 |
This.GetItem(oldhandle, l_tviold) |
|
1 |
|
1 |
// get the treeview item that is currently selected |
|
1 |
This.GetItem(newhandle, l_tvinew) |
|
1 |
|
1 |
// Display the labels for the two items in sle_get |
|
1 |
sle_get.Text = "Selection changed from " & |
|
1 |
   + String(l_tviold.Label) + " to " & |
|
1 |
   + String(l_tvinew.Label) |