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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridDropDownCellRenderer and DataRow

Thread ID:

Created:

Updated:

Platform:

Replies:

25803 Mar 8,2005 08:53 AM UTC Mar 8,2005 01:14 PM UTC WinForms 3
loading
Tags: GridControl
TheoC
Asked On March 8, 2005 08:53 AM UTC

Hi, I have a custom dropdown control that inherits from GridDropDownCellRenderer. The dropdown is used in gridgroupingcontrols and in a GridControl. I need to get the underlying current DataRow from the CurrentCell in the overriden OnInitialize(int rowIndex, int colIndex) method. Sorting and all other kinds of madness are possible so I can''t rely on the rowIndex or colIndex, just CurrentCell. Please help. Thanks, Theo C

Administrator [Syncfusion]
Replied On March 8, 2005 09:45 AM UTC

The CurrentCell is not always the cell that is passed to renderer.OnInitailize. In that event, you must get at the infromation using the passed in row and column. In a groupinggrid, you can get the record through the TableControl using code like: GridTableCellStyleInfo style = gridGroupingControl.TableControl.Model[row, col]; //get some record data GridRecordRow grr = style.TableCellIdentity.Table.DisplayElements[row] as GridRecordRow; DataRowView drv = grr.GetData() as DataRowView; SInce a GridControl does not have a DataSource, I am not sure how any datarow is being mapped into the GridControl. If you are using a virtual grid and displaying data through the DataTable.DefaultView, then you can get the data through the DataView (or through the CurrencyManager). Maybe like this: DataRowView drv = dataView1[row-1]; where dataView1 is the dataview you are using to provide the sorted data.

TheoC
Replied On March 8, 2005 12:38 PM UTC

Thank you for the response, this does not seem to work though. The grr.GetData() allways returns null. I modified the code (last line) to look like this: GridStyleInfo gsi = this.Grid.Model [this.CurrentCell.RowIndex, this.CurrentCell.ColIndex]; GridTableCellStyleInfoIdentity gtsi = (GridTableCellStyleInfoIdentity) gsi.CellIdentity; DataRow current_row = (DataRow)gtsi.DisplayElement.EngineTable.CurrentRecordManager.Data; Which seems to work fine for the parent table, but not for the Nested tables. Why doesn''t it work. Thank you for the assistance Theo C

TheoC
Replied On March 8, 2005 01:14 PM UTC

Ok, so I its workin now. I got it to work by doing the following from within the Custom Dropdown OnInitialize method: GridTableCellStyleInfo gsi = (GridTableCellStyleInfo) this.Grid.Model[rowIndex, colIndex]; GridTableCellStyleInfoIdentity gtsi = (GridTableCellStyleInfoIdentity) gsi.CellIdentity; GridRecordRow grr = gtsi.Table.DisplayElements[rowIndex] as GridRecordRow; DataRow current_row = (DataRow) grr.GetData(); Hope that helps anyone. Thanks

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;