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

RadGridView and Editfields bound to the same datasource not synchronized

1 Answer 98 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Pijus
Top achievements
Rank 1
Pijus asked on 27 Dec 2010, 03:00 PM
Hello all.
I see a strange behaviour when using the RadGridView instead of the DataGridView.
The grid's property is set to not allow to add new lines and not to be editable.

I have a win form with a DataGridView and two edit fields and a binding navigator.The DataGridView and the edit fields are bound to a database table.
If i press the „Add“ button in the binding navigator, the DataGridView scrolls down to the bottom, adds an empty line at the bottom and the two edit fields are cleared. After entering data in the edit fields, and selecting any other items in the DataGridView, the values from the edit fields are shown in the new line at the bottom of the grid.

Now I have replaced the DataGridView with the RadGridView 2010 Q3.

If I press the „Add“ button in the binding navigator, the RadGridView scrolls down (but not to the very bottom), adds an empty line at the bottom, however it does not scroll to this new line. So it’s invisible until the user scrolls the list to the end. The two edit fields still have the content of the last selected item. They are not cleared. I can overwrite in the two edit fields the existing values with some new values. The new values are now in the dataset but the RadDataView is not updated with the new values. At the bottom in the grid, there is still the new empty line. If I click on the empty line, the correct values are shown in the edit fields.
If I sort the RadGridView the empty line is updated with the value, entered in the edit field.

I want a behaviour like the .NET DataGridView.


I had a chance to install the 2009Q3 version of WinForms. And surprisingly here the behaviour is as I have expected (same as MS DataGridView).

So this leads to the conclusion, that between the versions 2009Q3 and 2010Q3 there was introduced a problem with the update mechanism.

1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 29 Dec 2010, 06:05 PM
Hello Pijus,

Thank you for your question.

I confirm that the described issue appears in our latest release. It is logged in our bug tracking system and it will be addressed in one of our upcoming releases. You should handle the RowsChanged event of RadGridView in order to work around the issue:

private void radGridView1_RowsChanged(object sender, Telerik.WinControls.UI.GridViewCollectionChangedEventArgs e)
{
    if (e.Action != Telerik.WinControls.Data.NotifyCollectionChangedAction.Add)
    {
        return;
    }
 
    if (this.bindingSource1.Current != null)
    {
        this.bindingSource1.ResetCurrentItem();
        this.radGridView1.CurrentRow = null;
        this.radGridView1.CurrentRow = e.NewItems(0);
    }
}

Resetting the current item in the BindingSource updates the values in all additional controls on the form which uses this source. In addition you should reset the current row in RadGridView in order to correct the control scroll bar value.

I hope it helps.

Best regards,
Alexander
the Telerik team
Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
Tags
GridView
Asked by
Pijus
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Share this question
or