我有一个问题,那就是我已成功从c sharp中的数据库生成树视图列表。父节点和子节点都没问题。问题是我可以通过单击节点来调用相应的表单。表单名称存储在数据库中。有没有办法做到这一点。我是树视图控件的新手。
string qry = "select * from payroll_forms where level_id='100'";
DataTable dt = new DataTable();
SqlDataAdapter adp = new SqlDataAdapter(qry, con);
DataTable dt_child = new DataTable(); ;
SqlDataAdapter adp_child;
adp.Fill(dt);
TreeNode childnode = null;
string qry_child = string.Empty;
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
dt_child.Clear();
parentnode = treeView1.Nodes.Add(dt.Rows[i]["form_caption"].ToString());
qry_child = "select * from payroll_forms where level_id !=100 and parent_id='" + dt.Rows[i]["form_no"] + "'";
adp_child = new SqlDataAdapter(qry_child, con);
adp_child.Fill(dt_child);
if (dt_child.Rows.Count > 0)
{
for (int j = 0; j < dt_child.Rows.Count; j++)
{
childnode = parentnode.Nodes.Add(dt_child.Rows[j]["form_caption"].ToString());
}
}
}`