public void InitControl(SqlConnectionStringBuilder conn, string schema) { groupBox1.Controls.Clear(); TableBusiness tableBusiness = new TableBusiness(); try { List <Table> lstTable = tableBusiness.ListTables(conn, schema); TreeView tree = new TreeView(); tree.ImageList = lstImage; tree.Name = "tvTables"; tree.CheckBoxes = true; tree.AfterCheck += new TreeViewEventHandler(tree_AfterCheck); tree.Dock = DockStyle.Fill; AdvancedTreeNode node; AdvancedTreeNode nodeSon; foreach (Table table in lstTable) { node = new AdvancedTreeNode(); node.Checked = true; node.Text = table.Name; node.Value = table; node.SelectedImageIndex = (int)DBImage.TABLE; node.ImageIndex = (int)DBImage.TABLE; tree.Nodes.Add(node); foreach (Column column in table.Columns) { nodeSon = new AdvancedTreeNode(); nodeSon.Checked = true; nodeSon.Text = column.Name + " (" + ListarAtributos(column) + ")"; nodeSon.Value = column; nodeSon.SelectedImageIndex = GetImageIndex(column); nodeSon.ImageIndex = GetImageIndex(column); node.Nodes.Add(nodeSon); } } groupBox1.Controls.Add(tree); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public TreeView InitTreeView(string seach) { TableBusiness tableBusiness = new TableBusiness(); TreeView tree = new TreeView(); tree.Name = "tvTables"; tree.CheckBoxes = true; try { AdvancedTreeNode node; AdvancedTreeNode nodeSon; List <Table> lstTable = tableBusiness.ListTables(ConnBuilder, seach); foreach (Table table in lstTable) { node = new AdvancedTreeNode(); node.Checked = true; node.Text = table.Name; node.Value = table; node.SelectedImageIndex = (int)DBImage.TABLE; node.ImageIndex = (int)DBImage.TABLE; tree.Nodes.Add(node); foreach (Column column in table.Columns) { nodeSon = new AdvancedTreeNode(); nodeSon.Checked = true; nodeSon.Text = column.Name + " (" + ListarAtributos(column) + ")"; nodeSon.Value = column; nodeSon.SelectedImageIndex = GetImageIndex(column); nodeSon.ImageIndex = GetImageIndex(column); node.Nodes.Add(nodeSon); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(tree); }