Hi,
When I move by mistakes a node on the node over him, the application crash with the error bellow.
To reproduce this,
> Create a treeView with 2 nodes inside!
> Move the second node into the first one,
> Do it again (Move the second node that is already into the first one exactly as you did before)
I hope you can reproduce it and tell me how to avoid this problem.
Best regards, Fred
private
void
frmMain_Load(
object
sender, EventArgs e)
{
DataSet ds =
new
DataSet();
DataRelation relation;
string
connectionString =
"server=MYSQLSERVER;database=MyStore;uid=FakeUserID;pwd=FakePassword"
;
SqlConnection mySqlConnection =
new
SqlConnection(connectionString);
string
strCustomer_Query =
"Select * from Customer"
;
string
strPurchases_Query =
"Select * from Purchases"
;
try
{
SqlCommand sql_Customer =
new
SqlCommand(strCustomer_Query, mySqlConnection);
SqlDataAdapter da =
new
SqlDataAdapter(sql_Customer);
da.Fill(ds,
"Customer"
);
da.SelectCommand.CommandText = strPurchases_Query;
da.Fill(ds,
"Purchases"
);
// Add the relation. Maybe this is not needed because we use the RelationBindings of the RadTreeView
DataColumn parentCol = ds.Tables[
"Customer"
].Columns[
"ID"
];
DataColumn childCol = ds.Tables[
"Purchases"
].Columns[
"Customer_ID"
];
relation =
new
DataRelation(
"Customer_Purchases"
, parentCol, childCol);
ds.Relations.Add(relation);
treeView1.ShowLines =
true
;
treeView1.RelationBindings.Add(
new
RelationBinding(ds,
"CustomerName"
,
"Customer_ID"
,
"PurchaseID"
,
"ID"
));
treeView1.DataSource = ds;
treeView1.DisplayMember =
"CustomerName"
;
treeView1.ValueMember =
"ID"
;
treeView1.ParentMember =
"ID"
;
treeView1.ChildMember =
"PurchaseID"
;
treeView1.ExpandAll();
}
private void InitPvProductCategoryTree()
{
ProductDAO proDao = new ProductDAO();
List<ProductCategory> categorys = proDao.GetAllCategoryList("");
tbxCategroy.DisplayMember = "CategoryName";
this.tbxCategroy.ValueMember = "ProductCategoryID";
this.tbxCategroy.ParentIDMember = "ParentID";
this.tbxCategroy.DataSource = categorys;
// this.tbxCategroy.DataMember = "Nodes";
}
private
string
ConvertDataToString(
bool
onlySelectedRows)
{
StringBuilder sbTextData =
new
StringBuilder();
// Copy columns header
foreach
(GridViewColumn col
in
this
.radGridView.Columns)
{
sbTextData.Append(col.HeaderText.Replace(
"\n"
,
" "
) +
"\t"
);
}
sbTextData.Append(
"\n"
);
// Convert only selected rows
if
(onlySelectedRows)
{
foreach
(GridViewRowInfo row
in
this
.radGridView.SelectedRows)
{
int
i = 0;
while
(i < row.Cells.Count)
{
if
(i > 0)
{
sbTextData.Append(
"\t"
);
}
if
(row.Cells[i].ColumnInfo
is
GridViewComboBoxColumn)
{
// Obtain displayed data
}
else
if
(row.Cells[i].Value ==
null
)
{
sbTextData.Append(
string
.Empty);
}
else
{
sbTextData.Append(row.Cells[i].Value.ToString());
}
i++;
}
sbTextData.Append(
"\n"
);
}
}
else
{
foreach
(GridViewRowInfo row
in
this
.radGridView.Rows)
{
int
i = 0;
while
(i < row.Cells.Count)
{
if
(i > 0)
{
sbTextData.Append(
"\t"
);
}
if
(row.Cells[i].Value ==
null
)
{
sbTextData.Append(
string
.Empty);
}
else
{
sbTextData.Append(row.Cells[i].Value.ToString());
}
i++;
}
sbTextData.Append(
"\n"
);
}
}
return
sbTextData.ToString();
}