private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Node.Parent != null && e.Node.Parent.Text == "表") { tabName = e.Node.Text; DataTable dt = CreateHelper.GetSyscolumns(sql_connectstring.Replace("Provider=sqloledb;", ""), e.Node.Text); this.dataGridView1.DataSource = dt; //数据源 this.dataGridView1.AutoGenerateColumns = false; //不自动 } else if (e.Node.Parent != null && e.Node.Parent.Text == "试图") { tabName = e.Node.Text; DataTable dt = CreateHelper.GetVSyscolumns(sql_connectstring.Replace("Provider=sqloledb;", ""), e.Node.Text); this.dataGridView1.DataSource = dt; //数据源 this.dataGridView1.AutoGenerateColumns = false; //不自动 } }
private void 批量生成ToolStripMenuItem_Click(object sender, EventArgs e) { List <TreeNode> listNodes = new List <TreeNode>(); foreach (TreeNode node in treeView1.Nodes) { if (node.Text == "表") { foreach (TreeNode childnode in node.Nodes) { if (childnode.Checked) { tabName = childnode.Text; DataTable dt = CreateHelper.GetSyscolumns(sql_connectstring.Replace("Provider=sqloledb;", ""), childnode.Text); dt.TableName = tabName; CreateFunc(dt); } } } else { foreach (TreeNode childnode in node.Nodes) { if (childnode.Checked) { tabName = childnode.Text; DataTable dt = CreateHelper.GetVSyscolumns(sql_connectstring.Replace("Provider=sqloledb;", ""), childnode.Text); dt.TableName = tabName; CreateFunc(dt); } } } // FindCheckNode(node, listNodes); } MessageBox.Show("生成成功!!!!"); }