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 CellButtonClick event. The caption of the push button is specified by the CellCaption 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 Gantt1
    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_gantt.GetVisualAppearance().Add( 0x20, COleVariant(_T("D:\\Temp\\ExGantt.Help\\buttonu.ebn")) );
m_gantt.GetVisualAppearance().Add( 0x21, COleVariant(_T("D:\\Temp\\ExGantt.Help\\buttond.ebn")) );
m_gantt.SetBackground( 2 /*exCellButtonUp*/, 0x20000000 );
m_gantt.SetBackground( 3 /*exCellButtonDown*/, 0x21000000 );

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

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

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

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

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

With thisform.Gantt1
    With .VisualAppearance
        .Add(32, "D:\Temp\ExGantt.Help\buttonu.ebn")
        .Add(33, "D:\Temp\ExGantt.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 Gantt1_AddItem(ByVal Item As EXGANTTLibCtl.HITEM)
    Gantt1.Items.CellHasButton(Item, 0) = True
End Sub

Private Sub Gantt1_CellButtonClick(ByVal Item As EXGANTTLibCtl.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 Gantt1.Items
    .CellHasButton(.FocusItem, 0) = True
End With 

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

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

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

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

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

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

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

with thisform.Gantt1.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:

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