Custom ComboBoxCellType Sample

Posted by: imgodot on 8 September 2017, 3:25 pm EST

  • Posted 8 September 2017, 3:25 pm EST

    Is there a COMPLETE working sample of a custom ComboBoxCellType that implements all the control properties like "Items", "ItemData", etc. and handles databinding in the same way as the standard cell-type?

    Thanks.
    -- Paul
  • Replied 8 September 2017, 3:25 pm EST

    Hi Paul,

    Here is the list of all methods/properties of ComboBoxCellType which you override as per your requirement while creating the custom comboboxcelltype.
    http://sphelp.grapecity.com/WebHelp/SpreadNet10/WF/webframe.html#FarPoint.Win.Spread~FarPoint.Win.Spread.CellType.ComboBoxCellType_members.html

    We have so many examples for Custom Combobox celltyoe over forums which you can go through.

    In case you are looking for something specific, please let me know.

    Regards,
    Deepak Sharma
  • Replied 8 September 2017, 3:25 pm EST

    There truly are lots of examples in the forums; and I've looked at quite a number of them.
    However, most of the examples are from users (many of which don't work right) or, are fragments and not complete examples or, require wading through forum posts for hours to find.

    Here, is what I am looking for; I would like a combo where:
    A) The combo can be bound to a database column which is defined as a varchar column (string value).
    B) The database column that is bound to the combo does NOT allow nulls.
    C) The combo Items and ItemData collections can be assigned programmatically.
    D) You can press Delete and have the combo SelectedIndex set to -1; so no item is selected.
    E) When the combo SelectedIndex = -1, the value that is assigned to the bound database column can be translated to a blank/empty string.

    Thanks.
    -- Paul

  • Replied 8 September 2017, 3:25 pm EST

    Hi Paul,
    Our default ComboBoxCelltype uses FpCombo as the editor for the cell.
    I would suggest you to catch the KeyDown/KeyPress event of FPCombo and set the value to null/nothing on Delete key. Something like:
    void fpSpread1_EditModeOn(object sender, EventArgs e)
    {
    if (fpSpread1.EditingControl is MyCombo)
    ((MyCombo)fpSpread1.EditingControl).KeyPress += new EventHandler(EditingControl_KeyPress);
    }


    Let me know if this does not help.

    Regards,
    Deepak Sharma

  • Replied 8 September 2017, 3:25 pm EST

    Deepak,

    Honestly, I expected more than that.
    When you offered help, I didn't expect it to only touch on a single aspect of the custom cell-type I was looking for.

    Also, the combo delete issue is an issue I have raised with Reeva (see post: "Set ComboBox CellType so no item is selected").
    She suggested the same thing you did and it does not work because the Delete key is not captured in all situations.
    My last post to her on the subject was SIX DAYS AGO with no response.

    -- Paul


  • Marked as Answer

    Replied 8 September 2017, 3:25 pm EST

    Hi Paul,

    I don't think we need to create a custom combobox here. We can simply handle the Delete key event for ComboBox editor and also set the value of ComboBox cell manually.

    Kevin has replied to your post here:
    http://sphelp.grapecity.com/forums/topic/set-combobox-celltype-so-no-item-is-selected/


    Regards,
    Deepak Sharma
Need extra support?

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

Learn More

Forum Channels