打开窗口后为什么没有初始化新窗口中的树形目录?帮看看
我想在SystemFrm窗口中双击树形目录后,打开PowerFrm窗口并初始moduleTreeView,但是现在没有显示出来PowerFrm窗口中的树形目录?是什么原因呢?
下面是PowerFrm初始时显示的树型目录代码:
private void PowerFrm_Load(object sender, EventArgs e)
{
SqlConnection moduleConn = new SqlConnection( "server=localhost;database=wms;uid=sa;pwd=sa ");
SqlCommand moduleCmd = moduleConn.CreateCommand();
moduleCmd.CommandText = "select * from modulelist ";
SqlDataAdapter moduleDa = new SqlDataAdapter(moduleCmd);
DataSet moduleDs = new DataSet();
moduleConn.Open();
moduleDa.Fill(moduleDs, "modulelist ");
moduleConn.Close();
foreach (DataRow dr in moduleDs.Tables[ "modulelist "].Rows)
{
TreeNode newNode = new TreeNode();
newNode.Tag = dr[ "id "];
newNode.Text = dr[ "name "].ToString();
moduleTreeView.Nodes.Add(newNode);
}
}
下面是SystemFrm窗口中打开PowerFrm的代码:
private void userTreeView_DoubleClick(object sender, EventArgs e)
{
if (checkChildFrmExist( "PowerFrm ") == true)
{
return;
}
else
{
PowerFrm newPowerFrm = new PowerFrm();