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.

Possible column index bug with ShowRowHeader

Thread ID:

Created:

Updated:

Platform:

Replies:

130316 May 5,2017 08:04 PM May 12,2017 12:47 AM WPF 3
loading
Tags: SfDataGrid
Sam Chan
Asked On May 5, 2017 08:04 PM

Hi,

If ShowRowHeader="False", I can lookup the index of a column using SfDataGrid.Columns.IndexOf() and then use that index in a call to SfDataGrid.MoveCurrentCell() to make a cell in that column current. However, if ShowRowHeader="True", the same call to MoveCurrentCell() would make the cell to the left of the intended cell current. This may be problematic because you have to check the current state of ShowRowHeader in order to offset the column index properly when setting a cell current.

Or should a different API be used to achieve selecting a current cell based on a column index independent of ShowRowHeader?

Regards,

Sam

Muthukumar Kalyanasundaram [Syncfusion]
Replied On May 9, 2017 11:56 PM

Hi Sam, 
 
Thank you for contacting Syncfusion support. 
 
We have checked your query.  You can achieve your requirement by two way as shown below. 
 
Way 1: You can resolve and get the appropriate column index by considering the ShowRowHeader  column as shown in the below code, 
 
Code Snippet: 
private void Button_Click(object sender, RoutedEventArgs e) 
{ 
    var colIndex = this.dataGrid.Columns.IndexOf(this.dataGrid.Columns["QS1"])+(this.dataGrid.ShowRowHeader?1:0); 
    this.dataGrid.MoveCurrentCell(new RowColumnIndex(1, colIndex), true); 
} 
 
Way 2: Also, you can use ResolveToScrollColumnIndex method to get the column index as shown below, 
 
Code Snippet: 
private void Button_Click1(object sender, RoutedEventArgs e) 
{ 
    var colIndex = this.dataGrid.Columns.IndexOf(this.dataGrid.Columns["QS1"]); 
    var index1 = this.dataGrid.ResolveToScrollColumnIndex(colIndex); 
    this.dataGrid.MoveCurrentCell(new RowColumnIndex(1, index1), true); 
} 
 
 
 
Please let us know if you have any query. 
 
Regards, 
Muthukumar K 
 


Sam Chan
Replied On May 11, 2017 06:55 AM

Hi Muthukumar,

Thank you for the reply. Both solutions work fine.

Regards,

Sam

Muthukumar Kalyanasundaram [Syncfusion]
Replied On May 12, 2017 12:47 AM

Hi Sam, 
 
Thanks for the update. Please let us know if you need any other assistance. 
 
Regards, 
Muthukumar K 


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.

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.

;