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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Using GetRecordStateAtRowIndex in PrepareViewStyleInfo

Thread ID:





27420 Apr 12,2005 03:04 PM UTC Apr 15,2005 12:14 PM UTC WinForms 4
Tags: GridControl
Asked On April 12, 2005 03:04 PM UTC

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 13, 2005 12:42 AM UTC

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 03:50 PM UTC

Tha worked Clay. Thanks.

Replied On April 15, 2005 12:08 PM UTC

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 12:14 PM UTC

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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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