Spread Windows Forms 15.0
Spread Windows Forms 15.0 Product Documentation / Developer's Guide / Cell Types / Working with Graphical Cell Types / Setting a Combo Box Cell / Allowing a Combo Box Cell to Handle a Double Click
In This Topic
    Allowing a Combo Box Cell to Handle a Double Click
    In This Topic

    By default, a combo box cell (ComboBoxCellType) cannot receive a double-click with the left mouse button. The cell goes into edit mode on the first click, so the next click goes to the FpCombo control that is the subeditor. To handle double-clicking on a combo box cell, use code based on the example shown here.

    For more information on the properties and methods of this cell type, refer to the ComboBoxCellType class.

    For information on the graphical cell types, refer to Working with Graphical Cell Types.

    For information on other features of cell types, refer to Understanding Additional Features of Cell Types.

    Using Code

    1. Define a combo box cell by creating an instance of the ComboBoxCellType class.
    2. Define the items in the combo box list.
    3. Handle the double-click event.

    Example

    This example provides an event when double-clicking on a combo cell.

    C#
    Copy Code
    private void Form1_Load(object sender, System.EventArgs e)
    {   FarPoint.Win.Spread.CellType.ComboBoxCellType c = new FarPoint.Win.Spread.CellType.ComboBoxCellType();
        c.Items = new String[] {"a", "b", "c"};
        fpSpread1.Sheets[0].Rows[0].CellType = c;
    }
    
    private void HeaderDoubleClick(object sender, System.EventArgs e)
    {
    //Add event code
    }
    
    private void fpSpread1_EditModeOn(object sender, System.EventArgs e)
    {
        FarPoint.Win.FpCombo c;
        if (fpSpread1.Sheets[0].ActiveRowIndex == 0)
        {
            c = ((FarPoint.Win.FpCombo)(fpSpread1.EditingControl));
            c.Click += new System.EventHandler(HeaderDoubleClick);
        } }
    
    VB
    Copy Code
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
         Dim c As New FarPoint.Win.Spread.CellType.ComboBoxCellType
         c.Items = New String() {"a", "b", "c"}
         fpSpread1.Sheets(0).Rows(0).CellType = c
    End Sub
    
    Private Sub HeaderDoubleClick(ByVal sender As Object, ByVal e As System.EventArgs)
    'Add event code
    End Sub
    
    Private Sub fpSpread1_EditModeOn(ByVal sender As Object, ByVal e As System.EventArgs) Handles fpSpread1.EditModeOn
         Dim c As FarPoint.Win.FpCombo
         If fpSpread1.Sheets(0).ActiveRowIndex = 0 Then
              c = CType(fpSpread1.EditingControl, FarPoint.Win.FpCombo)
              AddHandler c.Click, AddressOf HeaderDoubleClick
         End If
    End Sub
    
    See Also