本文整理汇总了C#中TreeNode.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNode.Remove方法的具体用法?C# TreeNode.Remove怎么用?C# TreeNode.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeNode
的用法示例。
在下文中一共展示了TreeNode.Remove方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestRemoveExistingNodeThatIsNotRoot
public void TestRemoveExistingNodeThatIsNotRoot()
{
var root = new TreeNode<int>(1);
root.Add(2);
root.Add(3);
root.Add(4);
root.Children.ElementAt(0).Add(5);
root.Children.ElementAt(1).Add(6);
root.Children.ElementAt(2).Add(7);
bool removalResult = root.Remove(6);
int[] expected = { 1, 2, 3, 4, 5, 7 };
var bfEnumerator = root.GetEnumerator(VisitType.BreadthFirst);
var elements = new List<int>();
while (bfEnumerator.MoveNext())
{
elements.Add(bfEnumerator.Current);
}
var actual = elements.ToArray();
Assert.IsTrue(removalResult);
Assert.AreEqual(expected.Length, actual.Length);
Assert.AreEqual(expected.Length, root.Count);
for (int i = 0; i < expected.Length; i++)
{
Assert.AreEqual(expected[i], actual[i]);
}
}
示例2: TestRemoveExistingNodeThatIsRoot
public void TestRemoveExistingNodeThatIsRoot()
{
var root = new TreeNode<int>(1);
root.Add(2);
root.Add(3);
root.Add(4);
root.Children.ElementAt(0).Add(5);
root.Children.ElementAt(1).Add(6);
root.Children.ElementAt(2).Add(7);
bool removeResult = root.Remove(1);
// the removal of the root element is not allowed
Assert.IsFalse(removeResult);
}
示例3: LoadFromSQL
private void LoadFromSQL()
{
try
{
Runtime.IsConnectionsFileLoaded = false;
if (_SQLUsername != "")
{
sqlCon =
new SqlConnection(
(string)
("Data Source=" + _SQLHost + ";Initial Catalog=" + _SQLDatabaseName + ";User Id=" +
_SQLUsername + ";Password=" + _SQLPassword));
}
else
{
sqlCon =
new SqlConnection("Data Source=" + _SQLHost + ";Initial Catalog=" + _SQLDatabaseName +
";Integrated Security=True");
}
sqlCon.Open();
sqlQuery = new SqlCommand("SELECT * FROM tblRoot", sqlCon);
sqlRd = sqlQuery.ExecuteReader(CommandBehavior.CloseConnection);
sqlRd.Read();
if (sqlRd.HasRows == false)
{
Runtime.SaveConnections();
sqlQuery = new SqlCommand("SELECT * FROM tblRoot", sqlCon);
sqlRd = sqlQuery.ExecuteReader(CommandBehavior.CloseConnection);
sqlRd.Read();
}
this.confVersion = Convert.ToDouble(sqlRd["confVersion"], CultureInfo.InvariantCulture);
TreeNode rootNode;
rootNode = new TreeNode((string)(sqlRd["Name"]));
Root.Info rInfo = new Root.Info(Root.Info.RootType.Connection);
rInfo.Name = rootNode.Text;
rInfo.TreeNode = rootNode;
rootNode.Tag = rInfo;
rootNode.ImageIndex = System.Convert.ToInt32(Images.Enums.TreeImage.Root);
rootNode.SelectedImageIndex = System.Convert.ToInt32(Images.Enums.TreeImage.Root);
if (Security.Crypt.Decrypt((string)(sqlRd["Protected"]), pW) != "ThisIsNotProtected")
{
if (Authenticate((string)(sqlRd["Protected"]), false, rInfo) == false)
{
Settings.Default.LoadConsFromCustomLocation = false;
Settings.Default.CustomConsPath = "";
rootNode.Remove();
return;
}
}
//Me._RootTreeNode.Text = rootNode.Text
//Me._RootTreeNode.Tag = rootNode.Tag
//Me._RootTreeNode.ImageIndex = Images.Enums.TreeImage.Root
//Me._RootTreeNode.SelectedImageIndex = Images.Enums.TreeImage.Root
sqlRd.Close();
// SECTION 3. Populate the TreeView with the DOM nodes.
AddNodesFromSQL(rootNode);
//AddNodeFromXml(xDom.DocumentElement, Me._RootTreeNode)
rootNode.Expand();
//expand containers
foreach (Container.Info contI in this._ContainerList)
{
if (contI.IsExpanded == true)
{
contI.TreeNode.Expand();
}
}
//open connections from last mremote session
if (Settings.Default.OpenConsFromLastSession == true && Settings.Default.NoReconnect == false)
{
foreach (Connection.Info conI in this._ConnectionList)
{
if (conI.PleaseConnect == true)
{
Runtime.OpenConnection(conI);
}
}
}
//Tree.Node.TreeView.Nodes.Clear()
//Tree.Node.TreeView.Nodes.Add(rootNode)
AddNodeToTree(rootNode);
//.........这里部分代码省略.........