Record.SetCurrent() changes current record but doesn't highlight the new row for Winforms GridGroupControl.

I'm trying to get the gridgroupcontrol to highlight the row just as it would if I select the row with a mouse. I am noticing that the row header is changing to signify that the current row index has changed but the row isn't highlighting. I did have this at some point working but feel there must be a setting for the grid that controls this behaviour. 

I don't want to use SetSelected(true) just SetCurrent().

I have attached a demo project along with a couple of screenshots that shows what I'm seeing. 

The code in question is below:

        private void selectNextRowButton_Click(object sender, EventArgs e)
        {
            var record = documentsGrid.Table.CurrentRecord;
            if (record != null)
            {
                documentsGrid.Table.Records[documentsGrid.Table.Records.IndexOf(record)+1].SetCurrent();
            }
        }

Thanks in advance.

Attachment: SetCurrent_Problem_Solution_386ca716.zip

1 Reply

SN Sindhu Nagarajan Syncfusion Team May 17, 2018 12:26 PM UTC

Hi Adam, 
 
Thanks for using Syncfusion products. 
 
We have analyzed the sample that you provided. In the sample, you have enabled both of the selection modes(i.e. ListBoxSelectionMode and AllowSelection). In that scenario, AllowSelection selection mode will be enabled and  the selected records will not be added to the SelectedRanges. So, if you want to move the selection to next row, add the next rowIndex to the SelectedRanges by using TableModel.SelectedRanges.Add() method. Please make use of the below code and sample, 
 
Code Example 
private void selectNextRowButton_Click(object sender, EventArgs e) 
{ 
    var record = documentsGrid.Table.CurrentRecord; 
    if (record != null) 
    { 
        //If ListBoxSelectionMode property is used for selection 
        documentsGrid.Table.Records[documentsGrid.Table.Records.IndexOf(record)+1].SetCurrent();   
        //If AllowSelection property is used.                          
        int index = documentsGrid.Table.CurrentRecord.GetRowIndex(); 
        documentsGrid.TableModel.SelectedRanges.Clear(); 
        documentsGrid.TableModel.SelectedRanges.Add(GridRangeInfo.Row(index)); 
    } 
} 
 
 
Note: The above solution can be applied when you are using AllowSelection property for selections. If you are using ListBoxSelectionMode property, then SetCurrent() method alone is enough to set the current row. Please refer to the below KB document and  UG link to know about the types of selections, 
 
  
Please let us know if you have any other queries. 
 
Regards, 
Sindhu  


Loader.
Up arrow icon