Problem on move the current row on the grid

3 posts, 0 answers
  1. Andrea
    Andrea avatar
    76 posts
    Member since:
    Oct 2012

    Posted 15 Nov 2016 Link to this post

    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. Andrea
    Andrea avatar
    76 posts
    Member since:
    Oct 2012

    Posted 16 Nov 2016 in reply to Andrea Link to this post

    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
               

  3. Dimitar
    Admin
    Dimitar avatar
    2951 posts

    Posted 16 Nov 2016 Link to this post

    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.
Back to Top