property Items.SelectItem(Item as HITEM) as Boolean

Selects or unselects a specific item.

TypeDescription
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 AllowSelectObjects property allows users to select at runtime the bars and links in the chart area. Use the ItemBar(exBarSelected) property to select or unselect programmatically a bar. Use the Link(exLinkSelected) property to select or unselect programmatically a link.

The following VB sample shows how to select the first created item: G2antt1.Items.SelectItem(G2antt1.Items(0)) = True

The following VB sample selects the first visible item:

With G2antt1.Items
    .SelectItem(.FirstVisibleItem) = True
End With

The following VB sample enumerates the selected items:

Dim i As Long
With G2antt1.Items
    For i = 0 To .SelectCount - 1
        Debug.Print .CellValue(.SelectedItem(i), 0)
    Next
End With

The following C++ sample selects the first visible item:

#include "Items.h"
CItems items = m_g2antt.GetItems();
items.SetSelectItem( items.GetFirstVisibleItem(), TRUE );

The following C++ sample unselects all items in the control:

m_g2antt.BeginUpdate();
CItems items = m_g2antt.GetItems();
while ( items.GetSelectCount() )
	items.SetSelectItem( items.GetSelectedItem( 0 ), FALSE );
m_g2antt.EndUpdate();

The following VB.NET sample selects the first visible item:

With AxG2antt1.Items
    .SelectItem(.FirstVisibleItem) = True
End With

The following VB.NET sample unselects all items in the control:

With AxG2antt1
    .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:

axG2antt1.Items.set_SelectItem(axG2antt1.Items.FirstVisibleItem, true);

The following C# sample unselects all items in the control:

axG2antt1.BeginUpdate();
EXG2ANTTLib.Items items = axG2antt1.Items;
while (items.SelectCount != 0)
	items.set_SelectItem(items.get_SelectedItem(0), false);
axG2antt1.EndUpdate();

The following VFP sample selects the first visible item:

with thisform.G2antt1.Items
	.DefaultItem = .FirstVisibleItem
	.SelectItem(0) = .t.
endwith

The following VFP sample unselects all items in the control:

With thisform.G2antt1
	.BeginUpdate()
	with .Items
		do while ( .SelectCount() # 0 )	
			.DefaultItem = .SelectedItem(0)
			.SelectItem(0) = .f.
		enddo
	endwith
	.EndUpdate()
EndWith