// update table tree to reflect new connection string private void UpdateTableTree() { // initialize table tree NGTreeNode rootNode = new NGTreeNodeWithImageIndex(); var ndTables = new NGTreeNodeWithImageIndex { Text = Current.ResourceService.GetString("Gui.DataConnection.Tables"), ImageIndex = 0, SelectedImageIndex = 0 }; var ndViews = new NGTreeNodeWithImageIndex { Text = Current.ResourceService.GetString("Gui.DataConnection.Views"), ImageIndex = 1, SelectedImageIndex = 1 }; // populate using current schema if (Schema != null) { // populate the tree foreach (System.Data.DataTable dt in Schema.Tables) { // create new node, save table in tag property var node = new NGTreeNodeWithImageIndex { Text = dt.TableName }; node.Tag = dt; // add new node to appropriate parent switch (OleDbSchema.GetTableType(dt)) { case TableType.Table: ndTables.Nodes.Add(node); node.ImageIndex = node.SelectedImageIndex = 0; AddDataColumns(node, dt); break; case TableType.View: ndViews.Nodes.Add(node); node.ImageIndex = node.SelectedImageIndex = 1; AddDataColumns(node, dt); break; } } // add non-empty nodes to tree foreach (NGTreeNode nd in new NGTreeNode[] { ndTables, ndViews }) { if (nd.Nodes.Count > 0) { nd.Text = string.Format("{0} ({1})", nd.Text, nd.Nodes.Count); rootNode.Nodes.Add(nd); } } // expand tables node ndTables.IsExpanded = true; _treeTableNodes = rootNode; if (null != _view) { _view.SetTableTreeDataSource(_treeTableNodes); } } }
private void UpdateTableTree() { // initialize table tree var nodes = _treeRootNode.Nodes; nodes.Clear(); var ndTables = new NGTreeNodeWithImageIndex() { Text = Current.ResourceService.GetString("Gui.DataConnection.Tables"), ImageIndex = 0, SelectedImageIndex = 0 }; var ndViews = new NGTreeNodeWithImageIndex() { Text = Current.ResourceService.GetString("Gui.DataConnection.Views"), ImageIndex = 1, SelectedImageIndex = 1 }; var ndProcs = new NGTreeNodeWithImageIndex() { Text = Current.ResourceService.GetString("Gui.DataConnection.StoredProcedures"), ImageIndex = 2, SelectedImageIndex = 2 }; // populate using current schema if (_schema != null) { // populate the tree foreach (System.Data.DataTable dt in _schema.Tables) { // create new node, save table in tag property var node = new NGTreeNodeWithImageIndex() { Text = dt.TableName }; node.Tag = dt; if (IsTableNameIdentical(dt.TableName, TableName)) { node.IsExpanded = true; node.IsSelected = true; } // add new node to appropriate parent switch (OleDbSchema.GetTableType(dt)) { case TableType.Table: ndTables.Nodes.Add(node); node.ImageIndex = node.SelectedImageIndex = 0; break; case TableType.View: ndViews.Nodes.Add(node); node.ImageIndex = node.SelectedImageIndex = 1; break; case TableType.Procedure: ndProcs.Nodes.Add(node); node.ImageIndex = node.SelectedImageIndex = 2; break; } } // add non-empty nodes to tree foreach (NGTreeNode nd in new NGTreeNode[] { ndTables, ndViews, ndProcs }) { if (nd.Nodes.Count > 0) { nd.Text = string.Format("{0} ({1})", nd.Text, nd.Nodes.Count); nodes.Add(nd); } } // expand tables node ndTables.IsExpanded = true; // done if (null != _view) { _view.SetTreeSource(_treeRootNode); } } }