To reproduce:
1. Add a RadTreeView and a RadGridView
2. Use the following code snippet.
3. Select a node from the RadtreeView.
4. Activate the editor for the new row in RadGridView.
5. While the grid editor is active, select a new node in the tree.
public Form1()
{
InitializeComponent();
this.radGridView1.MasterTemplate.AddNewBoundRowBeforeEdit = true;
}
public class ClassA
{
public int Id { get; set; }
public string Name { get; set; }
public string Grade { get; set; }
public ClassA()
{
}
public ClassA(int id, string name, string grade)
{
this.Id = id;
this.Name = name;
this.Grade = grade;
}
}
public class ClassB
{
public int NewID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public ClassB()
{
}
public ClassB(int id, string firstName, string lastName)
{
this.NewID = id;
this.FirstName = firstName;
this.LastName = lastName;
}
}
private void radTreeView1_SelectedNodeChanged(object sender, Telerik.WinControls.UI.RadTreeViewEventArgs e)
{
if (radGridView1.DataSource is BindingList<ClassA>)
{
this.radGridView1.Columns.Clear();
this.radGridView1.DataSource = null;
BindingList<ClassB> list = new BindingList<ClassB>() { new ClassB(1, "John", "Wick") };
this.radGridView1.DataSource = list;
}
else
{
this.radGridView1.DataSource = null;
BindingList<ClassA> list = new BindingList<ClassA>() { new ClassA(1,"John", "A+") };
this.radGridView1.Columns.Clear();
this.radGridView1.DataSource = list;
}
}
Workaround: this.radGridView1.MasterTemplate.AddNewBoundRowBeforeEdit = false;