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

Moving up/down with keyboard and getting current row index

Thread ID:

Created:

Updated:

Platform:

Replies:

144231 Apr 25,2019 07:15 PM UTC Apr 29,2019 10:49 AM UTC WinForms 1
loading
Tags: GridGroupingControl
Josip
Asked On April 25, 2019 07:15 PM UTC

Hi

How to get current row index while moving up/down with navigation keys?

I had tried on this way but I get wrong values. It starts row index from not 0.

this.gridAnalitika.TableOptions.AllowSelection = GridSelectionFlags.Row | GridSelectionFlags.AlphaBlend;

private void gridAnalitika_TableControlCurrentCellKeyDown(object sender, GridTableControlKeyEventArgs e)
{        

            GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.TableControl.CurrentCell.RowIndex, e.TableControl.CurrentCell.ColIndex);
            Record record = style.TableCellIdentity.DisplayElement.GetRecord();

            Console.WriteLine("Current row index: " + record.GetRowIndex());
}

My grid contains headers, filter columns and then data rows.

Thanks!

Sabaridass Ramamoorthy [Syncfusion]
Replied On April 29, 2019 10:49 AM UTC

Hi Josip, 
 
Thanks for contacting Syncfusion Support. 
 
As per the default behavior of GridGroupingControl, 0 is the index of GroupDropArea and 1 is the index of header rows. All the data rows have been started from index 2 based on the index of data row view in data table. If you are still would like get the row index starting from 0 means, you need to compute the row index based on the index of 0th row view of data table. We have prepared a simple sample to achieve your requirement and it can be downloaded from below location. 
 
Refer to the below code example. 
 
#Form1.cs 
 
private void GridGroupingControl1_TableControlCurrentCellKeyUp(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlKeyEventArgs e) 
        { 
            GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.TableControl.CurrentCell.RowIndex, e.TableControl.CurrentCell.ColIndex); 
            Record record = style.TableCellIdentity.DisplayElement.GetRecord(); 
            int startIndex = this.gridGroupingControl1.Table.Records[0].GetRowIndex(); 
            int actualIndex = record.GetRowIndex() - startIndex; 
            Console.WriteLine("Current row index: " + actualIndex); 
        } 
 
If the above solution doesn’t meet your actual requirement, kindly provide the detailed information about your requirement. So that it would be helpful for us to proceed further. 
 
Regards, 
Sabaridass R 


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.

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

Live Chat Icon For mobile
Live Chat Icon