Sets the value of an item in a list.
For use with DataWindows and DataStores, see the SetItem method for DataWindows in the section called “SetItem” in DataWindow Reference.
Description
Sets data associated with a ListView item to the property values you specify in a ListViewItem variable.
Applies to
ListView controls
Syntax
listviewname.SetItem ( index, { column }, item )
Argument |
Description |
---|---|
listviewname |
The ListView for which you are setting item properties |
index |
The index number of the item for which you are setting properties |
column |
The index number of the column of the item for which you want to set properties |
item |
The ListViewItem variable containing property values you want to assign to a ListView item |
Return value
Integer.
Returns 1 if it succeeds and -1 if an error occurs.
Usage
You can set properties for any ListView item with this syntax. If you do not specify a column, SetItem sets properties for the first column of an item. Only report views display multiple columns.
To add items to a ListView control, use the AddItem function. To add columns to a ListView control, use AddColumn. To set display values for the columns of a ListView item, use Syntax 2.
If you want to set column properties, such as alignment or width, use SetColumn. These column properties are independent of the ListViewItem objects.
To change pictures and other property values associated with a ListView item, use GetItem, change the property values, and use SetItem to apply the changes back to the ListView.
Examples
This example uses SetItem to change the state picture index for the selected lv_list ListView item:
listviewitem lvi_1 lv_list.GetItem(lv_list.SelectedIndex( ), lvi_1) lvi_1.StatePictureIndex = 2 lv_list.SetItem(lv_list.SelectedIndex () , lvi_1)
See also
Description
Sets the value displayed for a particular column of a ListView item.
Applies to
ListView control
Syntax
listviewname.SetItem ( index, column, label )
Argument |
Description |
---|---|
listviewname |
The ListView control for which you are setting a display value |
index |
The index number of the item for which you are setting a display value |
column |
The index number of the column for which you want to set a display value |
label |
The string value or variable which you are assigning to the specified column of the specified ListView item |
Return value
Integer.
Returns 1 if it succeeds and -1 if an error occurs.
Usage
You must include the column number as an argument, even if you are only assigning values to a single-column ListView control. To specify the properties for a ListView item, use Syntax 1.
Examples
This example assigns display values to three columns in a report view for three lv_list ListView items:
listviewitem l_lvi integer li_count, li_index FOR li_index = 1 to 3 li_count=li_count+1 lv_1ist.AddItem("Category " + String(li_index), 1) NEXT lv_list.AddColumn("Composition", Left! , 860) lv_list.AddColumn(" Album", Left! , 610) lv_list.AddColumn(" Artist", Left! , 710) lv_list.SetItem(1 , 1 , "St. Thomas") lv_list.SetItem(1 , 2 , "The Bridge") lv_list.SetItem(1 , 3 , "Sonny Rollins") lv_list.SetItem(2 , 1 , "So What") lv_list.SetItem(2 , 2 , "Kind of Blue") lv_list.SetItem(2 , 3 , "Miles Davis") lv_list.SetItem(3 , 1 , "Goodbye, Porkpie Hat") lv_list.SetItem(3 , 2 , "Mingus-Ah-Um") lv_list.SetItem(3 , 3 , "Charles Mingus")
See also
Description
Sets the data associated with a specified item.
Applies to
TreeView controls
Syntax
treeviewname.SetItem ( itemhandle, item )
Argument |
Description |
---|---|
treeviewname |
The name of the TreeView control in which you want to set the data for a specific item |
itemhandle |
The handle associated with the item you want to change |
item |
The TreeView item you want to change |
Return value
Integer.
Returns 1 if it succeeds and -1 if an error occurs.
Usage
Typically, you would call GetItem first, edit the data, and then call SetItem to reflect your changes in the TreeView control.
Examples
This example uses the ItemExpanding event to change the picture index and selected picture index of the current TreeView item:
treeviewitem l_tvi long ll_tvi ll_tvi = tv_list.FindItem(CurrentTreeItem! , 0) tv_list.GetItem(ll_tvi , l_tvi) l_tvi.PictureIndex = 5 l_tvi.SelectedPictureIndex = 5 tv_list.SetItem( ll_tvi, l_tvi )
See also