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

Selected row changing unexpectedly

7 Answers 80 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Alastair Waddell
Top achievements
Rank 1
Alastair Waddell asked on 07 Jan 2011, 08:06 AM
I am finding that if you have a sort on a colum and you edit that value so that it change position in the grid, that sometimes when you tab out of that field a completely different row is selected, and you are now editing the wrong cell.

I have been able to reproduce the behavior on the demo application - Gridview - Populate with data - select Dataset, sort by Postal Code 
 
Its doesnt happen every time on the demo, but it does on my application (Q3 2010)

ALastair

7 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 07 Jan 2011, 08:54 AM
Hello Alastair,

Sadly i was not able to reproduce that problem, (but maybe it is somehow changing the current row..) please take a look at the following example and tell me if you can reproduce it here, and if you cannot please try to modify it so that we can reproduce that bug and find a solution:
using System;
using System.Data;
using System.Windows.Forms;
using Telerik.WinControls.UI;
 
public partial class Form1 : Form
{
    private RadGridView radGridView1;
 
    public Form1()
    {
        InitializeComponent();
        this.Controls.Add(radGridView1 = new RadGridView());
        radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
        radGridView1.CellEndEdit += new GridViewCellEventHandler(radGridView1_CellEndEdit);
        radGridView1.Dock = DockStyle.Fill;
    }
 
    void radGridView1_CellEndEdit(object sender, GridViewCellEventArgs e)
    {
        radGridView1.CurrentRow = e.Row;
    }
 
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        radGridView1.DataSource = CreateAndPopulateDataSet();
        radGridView1.DataMember = "Table1";
    }
 
    public DataSet CreateAndPopulateDataSet()
    {
        var songDS = new DataSet();
        var songTable = songDS.Tables.Add();
        songTable.Columns.Add("ID", typeof(int));
        songTable.Columns.Add("Song", typeof(string));
 
        for (int i = 1; i < 10; i++)
        {
            songTable.Rows.Add(i, "Song " + i);
        }
 
        return songDS;
    }
}

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Alastair Waddell
Top achievements
Rank 1
answered on 07 Jan 2011, 09:43 AM
The code you sent worked ok, and I added the CellEndEdit to mine, but still have the problem.

Try this for me...

open your demo app, goto Gridview, goto Data Binding and change to Data Set.

Sort by the Postal code and edit Andrew Fullers post code to "1" and press the tab key.

On my system I see that Andrews Row goes to the top - which is what i expect - but you will notice that the country field which should have the focus doesnt.

If you do the same test but change the post code value to something that wont change the sort order, the country does have the focus.


Typically I cant repo the exact problem in the demo app.

I should also mention i have 300 ish rows on my grid - and i just noticed my error only comes when its going over the page. As in i can see 30 rows on the screen before i start scrolling.

A

0
Richard Slade
Top achievements
Rank 2
answered on 07 Jan 2011, 10:09 AM
Hello,

You've mentioned you are using Q3 2010, but is this the latest SP1 version? There were many fixes to the RadGridView in this service pack, and it would be worth updating if you are not on the current version. For reference the release note can be found here.
Let me know if that helps, or if you are using the latest I will try your exmaple.
Thanks
Richard
0
Alastair Waddell
Top achievements
Rank 1
answered on 07 Jan 2011, 10:16 AM
I am using 2010.3.10.1109 and my testing has just revealed that if i return 27 rows from my database i get the issue, but 26 rows it is ok. which is exactly how many row i can get on my screen.

I will try the SP over the weekend.


Alastair


0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 07 Jan 2011, 10:19 AM
Hi,

My first suspission is that this could be a scroll issue with the rows container. There were several that were addressed in the latest service pack. Are you able to install the latest service pack and retry your tests?
All the best
Richard
0
Alastair Waddell
Top achievements
Rank 1
answered on 10 Jan 2011, 01:31 AM
2010.3.10.1215 seems to have fixed the issue.


Alastair

0
Richard Slade
Top achievements
Rank 2
answered on 10 Jan 2011, 08:12 AM
Excellent. Please remember to mark as answer. Richard
Tags
GridView
Asked by
Alastair Waddell
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Alastair Waddell
Top achievements
Rank 1
Richard Slade
Top achievements
Rank 2
Share this question
or