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

Why CurrentRowChanged fires twice?

1 Answer 253 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Amador
Top achievements
Rank 1
Amador asked on 22 Dec 2012, 11:37 PM
Hi everybody.

I have a problem with CurrentRowChanged event of GridView. My problem is next.

At form's load event  I do this: (rgvClientes is the GridView)

this.rgvClientes.CurrentRow = null;
this.rgvClientes.CurrentRowChanged += new CurrentRowChangedEventHandler(this.rgvClientes_CurrentRowChanged);

And when I click on a Row from the GridView the event CurrentRowChanged fires twice but only the first time, after that it fires only ojne time when a click on a different row.

Someone can explaine me this issue?

Thanks an sorry about my English.

1 Answer, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 26 Dec 2012, 01:21 PM
Hello Amador, 

Thank you for writing.

I have tested the CurrentRowChanged event and I did not find any issues with the event raising. Here is a test application:

using System;
using System.Data;
using System.Windows.Forms;
using Telerik.WinControls.UI;
 
namespace Lab.Grid
{
    public partial class GridSelectionForm : Form
    {
        private RadGridView gridView = new RadGridView();
 
        public GridSelectionForm()
        {
            InitializeComponent();
 
            gridView.Dock = DockStyle.Fill;
            gridView.Parent = this;
             
            DataTable table = new DataTable();
            table.Columns.Add("Id");
            table.Columns.Add("Name");
 
            for (int i = 0; i < 10; i++)
            {
                table.Rows.Add(i, "Name" + i);
            }
 
            gridView.DataSource = table;
        }
 
        void gridView_CurrentRowChanged(object sender, CurrentRowChangedEventArgs e)
        {
            Console.WriteLine("Current Row Changed...");
        }
 
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
 
            gridView.CurrentRow = null;
            gridView.CurrentRowChanged += gridView_CurrentRowChanged;
        }
    }
}

The event is raised only once after first selection in RadGridView and on every new row selection. Please view the result in the attached screenshots.

Regards,
Julian Benkov
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
Tags
GridView
Asked by
Amador
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Share this question
or