method Editor.AddButton (Key as Variant, [Image as Variant], [Align as Variant], [ToolTip as Variant], [ToolTipTitle as Variant], [ShortcutKey as Variant])
Adds a new button to the editor with the given Key and aligned to the left or to the right side. You can specify the button's tooltip too.

TypeDescription
Key as Variant A Variant value that indicates the button's key. The ButtonClick event passes this value to Key parameter
Image as Variant A long expression that indicates the index of button's icon. The index is valid for Images collection. By default the button has no icon associated.
Align as Variant An AlignmentEnum expression that defines the button's alignment.
ToolTip as Variant A string expression that indicates the the button's tooltip description. The tooltip shows up when cursor hovers the button. The ToolTip parameter may include buitl-in HTML tags.
ToolTipTitle as Variant A string expression that indicates the tooltip's title.
ShortcutKey as Variant A short expression that indicates the shortcut key being used to simulate clicking the button. The lower byte indicates the code of the virtual key, and the higher byte indicates the states for SHIFT, CTRL and ALT keys ( last insignificant bits in the higher byte ). The ShortcutKey expression could be 256 *( ( shift ? 1 : 0 ) + (ctrl ? 2 : 0 ) + (alt ? 4 : 0) ) + vbKeyCode, For instance, a combination like CTRL + F3 is 256 * 2 + vbKeyF3, SHIFT + CTRL + F2 is 256 *(1 + 2) + vbKeyF2, and SHIFT + CTRL + ALT + F5 is 256 * (1 + 2 + 4) + vbKeyF5.

Use the AddButton method to add multiple buttons to the editor.  Make sure that you are using unique keys for the buttons in the same editor, else the previous button is replaced. The editor doesn't allow two buttons with the same key. Use the ButtonWidth property to set the button's width. If the user clicks on one of the editor buttons, the ButtonClick event is fired. Use CellHasButton property to display's the cell's caption as a button.  Use the RemoveButton method to remove a button that was previously added using the AddButton method. Use the ClearButtons method to clear the entire collection of buttons added with AddButton method. The control fires the ButtonClick event when the user clicks a button.

The following VB sample adds  multiple buttons to the column's editor:

With Grid1
    With .Columns.Add("Column 1")
        .HeaderBold = True
        .HeaderImage = 1
        With .Editor
            .EditType = DropDownListType
            .DropDownAutoWidth = False

            .AddItem 0, "CS is bad", 3
            .AddItem 1, "xTras is the worst", 3
            .AddItem 2, "Yes, I agree!", 3

            .ButtonWidth = 24
            .AddButton "Key1", 1, , "This is a bit of text that should appear while the cursor is over the button", "Information"
            .AddButton "Key2", 2
            .AddButton "Key3", 3, AlignmentEnum.RightAlignment
            .AddButton "Key3", 4, AlignmentEnum.RightAlignment
        End With
    End With
End With

The following VB sample adds an editor to the first visible item with three buttons, each of the button has a shortcut key to activate it using the keyboard:

With Grid1.Items
    With .CellEditor(.FirstVisibleItem, 0)
        .ButtonWidth = 20
        .EditType = EditType
        .AddButton "A", 1, , "You can click the button <fgcolor=000080><b>'A'</b></fgcolor> by pressing the <b>F3</b> key.", , vbKeyF3
        .AddButton "B", 2, RightAlignment, "You can click the button <fgcolor=000080><b>'B'</b></fgcolor> by pressing the <b>CTRL + F3</b> key.", , vbKeyF3 + (256 * (2))
        .AddButton "C", 3, , "You can click the button <fgcolor=000080><b>'C'</b></fgcolor> by pressing the <b>CTRL + ALT + F3</b> key.", , vbKeyF3 + (256 * (2 + 4))
    End With
End With

The following C++ sample adds an EditType editor with a button to the first visible item:

#include "Items.h"
#include "Editor.h"
COleVariant vtMissing; V_VT( &vtMissing) = VT_ERROR;
CItems items = m_grid.GetItems();
CEditor editor = items.GetCellEditor( COleVariant( items.GetFirstVisibleItem() ), COleVariant( long(0) ) );
editor.SetEditType( 1 /*EditType*/ );
editor.AddButton( COleVariant("A"), COleVariant("1"), vtMissing, vtMissing, vtMissing, vtMissing  );

The following VB.NET sample adds an EditType editor with a button to the first visible item:

With AxGrid1.Items
    With .CellEditor(.FirstVisibleItem, 0)
        .EditType = EXGRIDLib.EditTypeEnum.EditType
        .AddButton("A", 1)
    End With
End With

The following C# sample adds an EditType editor with a button to the first visible item:

EXGRIDLib.Items items = axGrid1.Items;
EXGRIDLib.Editor editor = items.get_CellEditor(items.FirstVisibleItem, 0);
editor.EditType = EXGRIDLib.EditTypeEnum.EditType;
editor.AddButton("A", 1, null, null, null, null);

The following VFP sample adds an EditType editor with a button to the first visible item:

with thisform.Grid1.Items
	With .CellEditor(.FirstVisibleItem, 0) 
		.EditType = 1 && EditType
		.AddButton("A", 1)
	EndWith
endwith