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.
Unfortunately, activation email could not send to your email. Please try again.

Using GetRecordStateAtRowIndex in PrepareViewStyleInfo

Thread ID:





27420 Apr 12,2005 11:04 AM Apr 15,2005 08:14 AM Windows Forms 4
Tags: GridControl
Asked On April 12, 2005 11:04 AM

I am attempting to use the code below in the PrepareViewStyleInfo to obtain the DataRow so that I may prepare how my GDBG is to look. The 1st and second rows will be retrieved properly, but the 3rd row and up all come back as the 2nd row. Any help would be appreciated. Thanks, Virgil Dim Row As DataRow Dim PartType As String Dim RecordState As GridBoundRecordState = _Grid.Binder.GetRecordStateAtRowIndex(e.RowIndex) Dim o As Object = RecordState.ListManager.Current Dim drv As DataRowView = CType(o, DataRowView) Row = drv.Row PartType = Row(ColumnNames.BaseQuoteData.PartType)

Administrator [Syncfusion]
Replied On April 12, 2005 08:42 PM

The row being drawn is not always the current record. It is only the record at e.RowIndex which may or may not be Current. Try: Dim drv As DataRowView = RecordState.Table(RecordState.Position)

Replied On April 13, 2005 11:50 AM

Tha worked Clay. Thanks.

Replied On April 15, 2005 08:08 AM

Clay, The code you provided works well except in the case of a new row. When mousing over the row, the following error is thrown (row #32 is the new row). An unhandled exception of type ''System.IndexOutOfRangeException'' occurred in system.data.dll Additional information: Index 32 is not non-negative and below total rows count.

Administrator [Syncfusion]
Replied On April 15, 2005 08:14 AM

Before trying to use it, check for valid values like RecordState.Position > -1 && RecordState.Position < RecordState.Table.Count Or, you could check e.RowIndex < grid.Model.RowCount. The AddNew row does not have a record associated with it until it is actually added.


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.

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.