We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How do I get the underlying datasource record when user enter a cell in the grid control

How do I get the underlying datasource record when user enter a cell in the grid control?

I trying to do that in the CellActivating event, which I am not sure is the right place to do this?

1 Reply

AD Administrator Syncfusion Team September 20, 2006 06:06 AM UTC

Hi James,

Issue 1:

Are you using the GridDataBoundGrid? If so, you can handle the CurrentCellActivated / CurrentCellMoved(For every cellmovement) event to get the record using the below code.

CurrencyManager cm = this.BindingContext[this.grid.DataSource] as CurrencyManager;
DataView dv = cm.List as DataView;
DataRowView currentRecord = cm.Current as DataRowView ;
Console.WriteLine(currentRecord[0]) ;

Refer the below forum thread for getting the selected rows in a grid. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=47865

Issue 2:

Are you using the GridControl? If so, you can handle the CurrentCellMoved event to get the cell values in a row using the below code.

//Bcoz Gridcontrol is a cell-based control..
GridControl grid = sender as GridControl;
GridCurrentCell cc = grid.CurrentCell;
for(int i = 1; i < grid.ColCount;i++)
Console.Write(" => " + grid.Model[cc.RowIndex,i].Text);
Console.WriteLine();

Let me know if this helps.

Thanks,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon