GridControl - data binding cells to custom classes

Are there any examples of binding cells to user defined classes for the GridControl? thanks, ak

4 Replies

AD Administrator Syncfusion Team July 6, 2005 08:25 AM UTC

One way that abitrary binding can be accomplished is by using the QuerycellInfo and SaveCellInfo events. In QueryCellInfo, if e.RowIndex and e.ColIndex point to your custom cell, then set e.Style.CellValue to be what you want it to be from your custom class ffrom that cell. You can set it to be some object, and the grid would display the object.ToString text in the cell. If you are trying to edit your custom object in the grid, in SaveCellInfo, if e.RowIndex and e.ColIndex point to your custom cell, then take the text from e.Style.Text and use it to modify your class object. Also set e.Handled = true so the grid does not to further process your object.


AK Adam K. July 6, 2005 01:02 PM UTC

do you have any example of this anywhere on the site? >One way that abitrary binding can be accomplished is by using the QuerycellInfo and SaveCellInfo events. > >In QueryCellInfo, if e.RowIndex and e.ColIndex point to your custom cell, then set e.Style.CellValue to be what you want it to be from your custom class ffrom that cell. You can set it to be some object, and the grid would display the object.ToString text in the cell. > >If you are trying to edit your custom object in the grid, in SaveCellInfo, if e.RowIndex and e.ColIndex point to your custom cell, then take the text from e.Style.Text and use it to modify your class object. Also set e.Handled = true so the grid does not to further process your object.


AD Administrator Syncfusion Team July 6, 2005 02:16 PM UTC

In this sample, cell 2,2 holds custom object. If you type T=Something you should see the cell display Something. If you type C=blue you shoul dsee teh cell turn blue. http://www.syncfusion.com/Support/user/uploads/GC_CustomObject_4549b667.zip


JB John Bowlin Bosco K Syncfusion Team January 4, 2011 01:03 PM UTC

Hi Nethanel,

Thank you very much for your update.

Currently In Essential XlsIO, we don’t have any methods to reflect the changes made in the Grid control. As a workaround, explicitly you can raise an event to export the Grid content to the Excel sheet when the Grid was modified . We have created a sample to update the data, please try the sample and let me know if this helps you.

Please let me know if you need any clarifications.

Thanks,
Pauline Bosco.




GridToExcel_2d70890.zip

Loader.
Up arrow icon