Combo Box Cell Does Not Show Options

Posted by: ryetek on 8 September 2017, 1:37 pm EST

  • Posted 8 September 2017, 1:37 pm EST


    Hello,


    The combo box cell does not show the options on the first click but only when edit mode is set to permanent. You need to click the combo icon a second time to get the selection list visible. Furthermore, still with edit mode set to permanent, if you click anywhere in the cell apart from the combo icon it shows the items on the first click. Has anyone seen this before? Is there a solution?

     


    Dim pCombo As CellType.ComboBoxCellType
    pCombo = New CellType.ComboBoxCellType

    pCombo.Items = New String() {"Item 1", "Item 2", "Item 3"}
    pCombo.Editable = False

    FpSpread1.ActiveSheet.Cells(0, 0).CellType = pCombo

    FpSpread1.EditModePermanent = True

     


    Thanks,


    Paul.

  • Replied 8 September 2017, 1:37 pm EST

    Paul -

    I am not seeing that behavior in my testing.  With EditModePermanent = True it only takes one click on the icon for the list to show up.  If you have a small project showing this behavior you can attach it and I will take a look.

  • Replied 8 September 2017, 1:37 pm EST

    Paul -

    The default behavior for the combobox is that the list will display on the first click in the cell regardless of where you are clicking.  This should be the same whether EditModePermanent is set or not.  There must be something else in your code that is preventing the list from displaying on the initial click when EditModePermanent is false.  If you want the list to only drop when clicking on the icon then you would have to create a custom celltype and override the IsReservedLocation and return Nothin if the user is clicking somewhere other than the icon.

  • Replied 8 September 2017, 1:37 pm EST

    Hi Bob,

    Thanks for the reply.

    The only code I have on my form is as included above. It's in the Form_Load event. The combo box works fine when EditModePermanent is set to false. You can click anywhere on the cell and the list items are shown. The problem comes when EditModePermanent is set to true (as per code snippet). If you click on any area of the cell except the icon the list items are shown and that's good; no problem. However if you click on the icon (as most users will I presume) the first click does nothing except set focus to the cell. A second click on the icon then shows the list. Finally when I say second click I don't mean double-click. Does this happen for you or not?

    I'm using VS2005 with no service pack and the latest (trial) version of Spread .NET for Windows Forms if this helps.

    Thanks,

    Paul.

  • Replied 8 September 2017, 1:37 pm EST

    Hi Bob,

    I have enclosed my project files. When you run the project firstly click on one of the non-combo cells. Now click back on the combo cell but directly on the drop-down icon. If it does for you what it's doing for me you will not see the list items. Now if you click the down-down icon again it will then show the items. Remember that if you click anywhere else on the cell it shows the list items on the first click as I would expect (well that how it's working here anyhow Confused).

    Many thanks,

    Paul. 


    2008/11/WindowsApplication2.zip
  • Replied 8 September 2017, 1:37 pm EST

    Paul -

    This is the intended behavior when clicking on the icon with EditModePermanent set to true.  To overcome this you can do the following...

    Private Sub FpSpread1_CellClick(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.CellClickEventArgs) Handles FpSpread1.CellClick

    If e.Column = 0 And e.Row = 0 Then
    e.Cancel = True
    FpSpread1.Sheets(0).SetActiveCell(e.Row, e.Column)
    CType(FpSpread1.EditingControl, FarPoint.Win.FpCombo).DroppedDown = True
    End If

    End Sub

  • Replied 8 September 2017, 1:37 pm EST


    Hi Bob,


    Thanks for looking at that. I worked out a slightly different solution whereby I would NOT initially set the EditModePermanent to true. Then in the EnterCell event I check to see if the cell type is a combo cell and if it isn't I turn on EditMode programmatically. This appears to work OK. However I think your solution is better overall.


    Once again thanks.


    Paul.




    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

            Dim pCombo As CellType.ComboBoxCellType
            pCombo = New CellType.ComboBoxCellType

            pCombo.Items = New String() {"Item 1", "Item 2", "Item 3"}
            pCombo.Editable = False

            FpSpread1.ActiveSheet.Cells(0, 0).CellType = pCombo


    End Sub

    Private Sub FpSpread1_EnterCell(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.EnterCellEventArgs) Handles FpSpread1.EnterCell

            If Not Convert.ToString(FpSpread1.ActiveSheet.GetCellType(e.Row,e.Column)) = "ComboBoxCellType" Then
                    e.View.EditMode = True
            End If

    End Sub


     

  • Replied 8 September 2017, 1:37 pm EST

    Paul -

    Whatever works best for you.  If you have any further questions let us know>

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels