Fired after the user clicks on the cell of button type.
![]() | Type | Description | ||
| Cell as HCELL | A long expression that indicates the handle of the cell being clicked. |
The CellButtonClick event is fired after the user has released the left mouse button over a cell of button type. Use the CellHasButton property to specify whether a cell is of button type. The CellButtonClick event notifies your application that user presses a cell of button type. Use the CellCaption property to determine the caption of the cell being clicked.
The following VB sample sets the cells of the first column to be of button type, and displays a message when one of them has been clicked.
Private Sub ComboBox1_InsertItem(ByVal Item As EXCOMBOBOXLibCtl.HITEM)
ComboBox1.Items.CellHasButton(Item, 0) = True
End Sub
Private Sub ComboBox1_CellButtonClick(ByVal Cell As EXCOMBOBOXLibCtl.HCELL)
MsgBox "The user clicks the cell's button. " & ComboBox1.Items.CellCaption(, Cell)
End Sub
The following C++ sample displays a message when the user clicks a button in the cell:
void OnCellButtonClickCombobox1(long Cell)
{
COleVariant vtMissing; V_VT( &vtMissing ) = VT_ERROR;
CString strCaption = V2S( &m_combobox.GetItems().GetCellCaption( vtMissing, COleVariant( (long)Cell ) ) );
MessageBox( "The cell of button type has been clicked." + strCaption );
}
where the V2S function converts a VARIANT expression to a string expression,
static CString V2S( VARIANT* pv, LPCTSTR szDefault = _T("") )
{
if ( pv )
{
if ( pv->vt == VT_ERROR )
return szDefault;
COleVariant vt;
vt.ChangeType( VT_BSTR, pv );
return V_BSTR( &vt );
}
return szDefault;
}
The following VB.NET sample displays a message when the user clicks a button in the cell:
Private Sub AxComboBox1_CellButtonClick(ByVal sender As Object, ByVal e As AxEXCOMBOBOXLib._IComboBoxEvents_CellButtonClickEvent) Handles AxComboBox1.CellButtonClick
MsgBox("The cell of button type has been clicked." & AxComboBox1.Items.CellCaption(, e.cell))
End Sub
The following C# sample displays a message when the user clicks a button in the cell:
private void axComboBox1_CellButtonClick(object sender, AxEXCOMBOBOXLib._IComboBoxEvents_CellButtonClickEvent e)
{
MessageBox.Show("The cell of button type has been clicked. " + axComboBox1.Items.get_CellCaption(null, e.cell).ToString() );
}
The following VFP sample displays a message when the user clicks a button in the cell:
*** ActiveX Control Event *** LPARAMETERS item, colindex wait window "The cell of button type has been clicked."