This is a migrated thread and some comments may be shown as answers.

Problem on move the current row on the grid

2 Answers 182 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Andrea
Top achievements
Rank 1
Andrea asked on 15 Nov 2016, 06:41 PM

Hello, i have the following code:

When the user press the down arrow, the grid goes to the first row instead of going to row 86.

How can I let the grid going to the row after the current when the user press the down arrow key?

Version of api is the latest (i didn't notice that in previous versions, I can't remember if previous version had same bahaviour, but I think not) OS is windows 10

Best regards

Andrea

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Telerik.WinControls.UI;
 
namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        RadGridView rgv;
        public Form1()
        {
            rgv = new RadGridView();
            rgv.Dock = DockStyle.Fill;
            this.Controls.Add(rgv);
            this.Size = new Size(800, 600);
             
             
            this.Load += Form1_Load;
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
            List<data> data = new List<WindowsFormsApplication2.data>();
            for (int i = 0; i < 100; ++i)
            {
                data.Add(new WindowsFormsApplication2.data { A = "test" });
            }
            int n = 85;
            rgv.DataSource = data;
            rgv.Rows[n].IsSelected = true;
            rgv.Rows[n].IsCurrent = true;
            rgv.Rows[n].EnsureVisible();
            rgv.CurrentRow = rgv.Rows[n];
        }
    }
 
    class data
    {
        public string A { get; set; }
    }
}

2 Answers, 1 is accepted

Sort by
0
Andrea
Top achievements
Rank 1
answered on 16 Nov 2016, 08:18 AM

I found a workaround on that, just invert

 

rgv.Rows[n].IsSelected = true;
rgv.Rows[n].IsCurrent = true;

to read

rgv.Rows[n].IsCurrent = true;
rgv.Rows[n].IsSelected = true;

or even remove the IsSelected is working.

maybe there is some race condition anyway for me the problem is solved.

Best Regards

Andrea
           

0
Dimitar
Telerik team
answered on 16 Nov 2016, 10:44 AM
Hi Andrea,

I am glad that this is working fine now.

It is ok the row to be Current and Selected detailed information is available here: Selected rows and Current row. In addition on my side, this is working fine with all configurations.

Please do not hesitate to contact us with any additional questions or concerns. 
 
Regards,
Dimitar
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Tags
GridView
Asked by
Andrea
Top achievements
Rank 1
Answers by
Andrea
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or