Completed
Last Updated: 28 Dec 2012 03:01 by ADMIN
ADMIN
Boryana
Created on: 28 Dec 2012 03:01
Category: TreeView
Type: Bug Report
1
FIX. RadTreeView bound to self referencing data throws exception when the user edits the root node.
The following code produces an error when the user attempts to edit the root node:
DataTable dt = new DataTable();
DataColumn column = new DataColumn("ID", typeof(int));
column.AllowDBNull = false;
column.AutoIncrement = true;
dt.Columns.Add(column);
dt.Columns.Add(new DataColumn("ParentID", typeof(int)));
dt.Columns.Add(new DataColumn("Name", typeof(string)));
dt.Columns.Add(new DataColumn("Note", typeof(string)));
dt.Rows.Add(1, DBNull.Value, "Root", "Note1");
dt.Rows.Add(2, 1, "First", "Note1");
dt.Rows.Add(3, 1, "Second", "Note1");
dt.Rows.Add(4, 3, "Third", "Note1");
this.radTreeView1.DisplayMember = "Name";
this.radTreeView1.ParentMember = "ParentID";
this.radTreeView1.ChildMember = "ID";
this.radTreeView1.ValueMember = "ID";
this.radTreeView1.DataSource = dt;
radTreeView1.TreeViewElement.EditMode = TreeNodeEditMode.Text;
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 Lab.Tree
{
public partial class TreeSelfreferenceEditRootNodeForm : Form
{
private RadTreeView treeView = new RadTreeView();
private BindingSource bindingSource = new BindingSource();
public TreeSelfreferenceEditRootNodeForm()
{
InitializeComponent();
treeView.Dock = DockStyle.Fill;
treeView.Parent = this;
treeView.AllowEdit = true;
DataTable dt = new DataTable();
DataColumn column = new DataColumn("ID", typeof(int));
column.AllowDBNull = false;
column.AutoIncrement = true;
dt.Columns.Add(column);
dt.Columns.Add(new DataColumn("ParentID", typeof(int)));
dt.Columns.Add(new DataColumn("Name", typeof(string)));
dt.Columns.Add(new DataColumn("Note", typeof(string)));
dt.Rows.Add(1, DBNull.Value, "Root", "Note1");
dt.Rows.Add(2, 1, "First", "Note1");
dt.Rows.Add(3, 1, "Second", "Note1");
dt.Rows.Add(4, 3, "Third", "Note1");
bindingSource.DataSource = dt;
treeView.DisplayMember = "Name";
treeView.ParentMember = "ParentID";
treeView.ChildMember = "ID";
treeView.ValueMember = "ID";
treeView.DataSource = bindingSource;
treeView.TreeViewElement.EditMode = TreeNodeEditMode.Text;
}
}
}
0 comments