property Items.CellHasButton([Item as Variant], [ColIndex as Variant]) as Boolean

Retrieves or sets a value indicating whether the cell has associated a push button or not.

TypeDescription
Item as Variant A long expression that indicates the item's handle.
ColIndex as Variant A long expression that indicates the column's index, a string expression that indicates the column's caption or the column's key.
Boolean A boolean expression that indicates whether the cell contains a button.

The CellHasButton property specifies whether the cell display a button inside. When the cell's button is clicked the control fires ButtonClick event. The caption of the push button is specified by the CellValue property. Use the Def property to assign buttons for all cells in the column. Use the Add method to add new skins to the control. Use the Background property to specify a background color or a visual appearance for specific parts in the control. See also: CellButtonAutoWidth property.

The following VB sample changes the appearance for buttons in the cells. The sample use the skin "" when the button is up, and the skin "" when the button is down:

With G2antt1
    With .VisualAppearance
        .Add &H20, App.Path + "\buttonu.ebn"
        .Add &H21, App.Path + "\buttond.ebn"
    End With
    .Background(exCellButtonUp) = &H20000000
    .Background(exCellButtonDown) = &H21000000
End With

The following C++ sample changes the appearance for buttons in the cells:

#include "Appearance.h"
m_g2antt.GetVisualAppearance().Add( 0x20, COleVariant(_T("D:\\Temp\\ExG2antt.Help\\buttonu.ebn")) );
m_g2antt.GetVisualAppearance().Add( 0x21, COleVariant(_T("D:\\Temp\\ExG2antt.Help\\buttond.ebn")) );
m_g2antt.SetBackground( 2 /*exCellButtonUp*/, 0x20000000 );
m_g2antt.SetBackground( 3 /*exCellButtonDown*/, 0x21000000 );

The following VB.NET sample changes the appearance for buttons in the cells.

With AxG2antt1
    With .VisualAppearance
        .Add(&H20, "D:\Temp\ExG2antt.Help\buttonu.ebn")
        .Add(&H21, "D:\Temp\ExG2antt.Help\buttond.ebn")
    End With
    .set_Background(EXG2ANTTLib.BackgroundPartEnum.exCellButtonUp, &H20000000)
    .set_Background(EXG2ANTTLib.BackgroundPartEnum.exCellButtonDown, &H21000000)
End With

The following C# sample changes the appearance for buttons in the cells.

axG2antt1.VisualAppearance.Add(0x20, "D:\\Temp\\ExG2antt.Help\\buttonu.ebn");
axG2antt1.VisualAppearance.Add(0x21, "D:\\Temp\\ExG2antt.Help\\buttond.ebn");
axG2antt1.set_Background(EXG2ANTTLib.BackgroundPartEnum.exCellButtonUp, 0x20000000);
axG2antt1.set_Background(EXG2ANTTLib.BackgroundPartEnum.exCellButtonDown, 0x21000000);

The following VFP sample changes the appearance for buttons in the cells.

With thisform.G2antt1
    With .VisualAppearance
        .Add(32, "D:\Temp\ExG2antt.Help\buttonu.ebn")
        .Add(33, "D:\Temp\ExG2antt.Help\buttond.ebn")
    EndWith
    .Object.Background(2) = 536870912
    .Object.Background(3) = 553648128
endwith

the 536870912 indicates the 0x20000000 value in hexadecimal, and the 553648128 indicates the 0x21000000 value in hexadecimal

The following VB sample sets the cells of the first column to be of button type, and displays a message if the button is clicked:

Private Sub G2antt1_AddItem(ByVal Item As EXG2ANTTLibCtl.HITEM)
    G2antt1.Items.CellHasButton(Item, 0) = True
End Sub

Private Sub G2antt1_ButtonClick(ByVal Item As EXG2ANTTLibCtl.HITEM, ByVal ColIndex As Long)
    MsgBox "The cell of button type has been clicked"
End Sub

The following VB sample assigns a button to the focused cell:

With G2antt1.Items
    .CellHasButton(.FocusItem, 0) = True
End With 

The following C++ sample assigns a button to the focused cell:

#include "Items.h"
CItems items = m_g2antt.GetItems();
items.SetCellHasButton( COleVariant( items.GetFocusItem() ), COleVariant( (long)0 ), TRUE );

The following VB.NET sample assigns a button to the focused cell:

With AxG2antt1.Items
    .CellHasButton(.FocusItem, 0) = True
End With

The following C# sample assigns a button to the focused cell:

axG2antt1.Items.set_CellHasButton(axG2antt1.Items.FocusItem, 0, true);

The following VFP sample assigns a button to the focused cell:

with thisform.G2antt1.Items
	.DefaultItem = .FocusItem
	.CellHasButton(0,0) = .t.
endwith

Note: A cell is the intersection of an item with a column. All properties that has an Item and a ColIndex parameters are referring to a cell. The Item parameter represents the handle of an item, and the ColIndex parameter indicates an index ( a numerical value, see Column.Index property ) of a column , the column's caption ( a string value, see Column.Caption property ), or a handle to a cell. Here's few hints how to use properties with Item and ColIndex parameters:

G2antt1.Items.CellBold(, G2antt1.Items.ItemCell(G2antt1.Items(0), 0)) = True
G2antt1.Items.CellBold(G2antt1.Items(0), 0) = True
G2antt1.Items.CellBold(G2antt1.Items(0), "ColumnName") = True