正好做类似的东西,给你一个吧
private void nodeselect(string nodeid)
{
try
{
if(nodeid=="0000")
{
this.richTextBox1.Text="";
this.richTextBox2.Text="";
}
else
{
string seltxt="select * from CTSDB.content where no_content='"+nodeid+"'";
getcon();
ds.Clear();
getdataset(seltxt);
this.richTextBox1.Text=ds.Tables["temp"].Rows[0]["contents"].ToString();
this.richTextBox2.Text=ds.Tables["temp"].Rows[0]["detail"].ToString();
}
}
catch(Exception err)
{
MessageBox.Show(err.Message);
}
}
private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
{
try
{
string nodename;
if(this.treeView1.SelectedNode.Nodes.Count == 0 )
nodename=this.treeView1.SelectedNode.Text;
else nodename="(0000)";
string nodenum = nodename.Substring(1, 4);
nodeselect(nodenum);
}
catch(Exception err)
{
MessageBox.Show(err.Message);
}
}