Selects or unselects a specific item.
Type | Description | |||
Item as HITEM | A long expression that indicates the item's handle that is selected or unselected. | |||
Boolean | A boolean expression that indicates the item's state. True if the item is selected, and False if the item is not selected. |
Use the SelectItem to select or unselect a specified item (that's selectable). Use the SelectableItem property to specify the user can select an item. Use the SelectCount property to get the number of selected items. Use the SelectedItem property to get the selected item. Use the FocusItem property to get the focused item. If the control supports only single selection, you can use the FocusItem property to get the selected/focused item because they are always the same. The control fires the SelectionChanged event when user selects an item. Use the SelForeColor and SelBackColor properties to specify colors for selected items. Use the SingleSel property to allow multiple selection. Use the SelectPos property to select an item giving its position. Use the EnsureVisibleItem property to ensure that an item is visible.
The following VB sample shows how to select the first created item: Gantt1.Items.SelectItem(Gantt1.Items(0)) = True
The following VB sample selects the first visible item:
With Gantt1.Items .SelectItem(.FirstVisibleItem) = True End With
The following VB sample enumerates the selected items:
Dim i As Long With Gantt1.Items For i = 0 To .SelectCount - 1 Debug.Print .CellCaption(.SelectedItem(i), 0) Next End With
The following C++ sample selects the first visible item:
#include "Items.h" CItems items = m_gantt.GetItems(); items.SetSelectItem( items.GetFirstVisibleItem(), TRUE );
The following C++ sample unselects all items in the control:
m_gantt.BeginUpdate(); CItems items = m_gantt.GetItems(); while ( items.GetSelectCount() ) items.SetSelectItem( items.GetSelectedItem( 0 ), FALSE ); m_gantt.EndUpdate();
The following VB.NET sample selects the first visible item:
With AxGantt1.Items .SelectItem(.FirstVisibleItem) = True End With
The following VB.NET sample unselects all items in the control:
With AxGantt1 .BeginUpdate() With .Items While Not .SelectCount = 0 .SelectItem(.SelectedItem(0)) = False End While End With .EndUpdate() End With
The following C# sample selects the first visible item:
axGantt1.Items.set_SelectItem(axGantt1.Items.FirstVisibleItem, true);
The following C# sample unselects all items in the control:
axGantt1.BeginUpdate(); EXGANTTLib.Items items = axGantt1.Items; while (items.SelectCount != 0) items.set_SelectItem(items.get_SelectedItem(0), false); axGantt1.EndUpdate();
The following VFP sample selects the first visible item:
with thisform.Gantt1.Items .DefaultItem = .FirstVisibleItem .SelectItem(0) = .t. endwith
The following VFP sample unselects all items in the control:
With thisform.Gantt1 .BeginUpdate() with .Items do while ( .SelectCount() # 0 ) .DefaultItem = .SelectedItem(0) .SelectItem(0) = .f. enddo endwith .EndUpdate() EndWith