Home Forums WinForms controls Xceed Grid for WinForms Nullable Types

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #15209 |

    Hey!,

    I have a custom IBindingList collection which I bind to the grid. The problem is that if I have objects in it which have nullable type properties then the values set in the cells are not committed.

    Please suggest a workaround.

    Imported from legacy forums. Posted by Hemanshu (had 3930 views)

    User (Old forums)
    Member
    Post count: 23064

    The editors do not support nullable data types. You need to subscribe to the SettingControlValue and GettingControlValue on the editors so that you can make the proper conversion, depending on the data type of the column.

    You will find an example of each event form the following help documentation pages :

    <a href=”http://doc.xceedsoft.com/products/XceedGrid/CellEditorManagers.html”>http://doc.xceedsoft.com/products/XceedGrid/CellEditorManagers.html</a&gt;
    <a href=”http://doc.xceedsoft.com/products/XceedGrid/CellViewerManagers.html”>http://doc.xceedsoft.com/products/XceedGrid/CellViewerManagers.html</a&gt;

    Imported from legacy forums. Posted by André (had 306 views)

    User (Old forums)
    Member
    Post count: 23064

    I did override the GetControlValueCore and all works fine…but is it possible to commit the value of the checkbox as soon as the checkstate changes? I dont want to wait until the user exits the cell or presses enter…how do i do that?

    Imported from legacy forums. Posted by Pitrick (had 354 views)

    User (Old forums)
    Member
    Post count: 23064

    This is only possible if you make the column ReadOnly, and change the value through code in the click event handler, or in the KeyUp event handler of the SpaceBar/Enter/whatever…

    Imported from legacy forums. Posted by André (had 260 views)

    User (Old forums)
    Member
    Post count: 23064

    Another option is to catch the CheckStateChanged-event on the editor control, and in the event handler call LeaveEdit on the cell:<pre>WinCheckBox lCheckBox = sender as WinCheckBox;
    GridControl lGrid = lCheckBox.Parent.Parent as GridControl;
    Cell lCell = lGrid.CurrentCell;
    if (lCell != null) lCell.LeaveEdit(true);</pre>

    Imported from legacy forums. Posted by Tommy (had 542 views)

    User (Old forums)
    Member
    Post count: 23064

    This is what i found worked… the only thing is you need to check that lCell.IsBeingEdited to avoid an exception…

    Thanks

    Imported from legacy forums. Posted by Pitrick (had 4917 views)

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.