本文整理汇总了C#中System.Windows.Forms.TreeView.Invoke方法的典型用法代码示例。如果您正苦于以下问题:C# TreeView.Invoke方法的具体用法?C# TreeView.Invoke怎么用?C# TreeView.Invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.TreeView
的用法示例。
在下文中一共展示了TreeView.Invoke方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InvokeAddNode
/// <summary>
/// Invoke方式添加TreeView的Node
/// </summary>
public static void InvokeAddNode(TreeView treeView, TreeNode node)
{
if (treeView.InvokeRequired)
{
treeView.Invoke(new MethodInvoker(() => { InvokeAddNode(treeView, node); }));
}
else
{
treeView.Nodes.Add(node);
}
}
示例2: AddNode
public static void AddNode(TreeView treeview, TreeNode node)
{
MethodInvoker mi = delegate
{
treeview.Nodes.Add(node);
};
if (treeview.InvokeRequired)
{
treeview.Invoke(mi);
}
else
{
mi();
}
}
示例3: ExpandAll
public static void ExpandAll(TreeView treeview)
{
MethodInvoker mi = delegate
{
treeview.ExpandAll();
};
if (treeview.InvokeRequired)
{
treeview.Invoke(mi);
}
else
{
mi();
}
}
示例4: ClearNodes
public static void ClearNodes(TreeView treeview)
{
MethodInvoker mi = delegate
{
treeview.Nodes.Clear();
};
if (treeview.InvokeRequired)
{
treeview.Invoke(mi);
}
else
{
mi();
}
}
示例5: GetSelectedNode
public static TreeNode GetSelectedNode(TreeView treeview)
{
TreeNode node = null;
MethodInvoker mi = delegate
{
node = treeview.SelectedNode;
};
if (treeview.InvokeRequired)
treeview.Invoke(mi);
else
mi();
return node;
}
示例6: GetNodes
public static TreeNodeCollection GetNodes(TreeView treeview)
{
TreeNodeCollection collection = null;
MethodInvoker mi = delegate
{
collection = treeview.Nodes;
};
if (treeview.InvokeRequired)
{
treeview.Invoke(mi);
}
else
{
mi();
}
return collection;
}
示例7: Sort
public static void Sort(TreeView treeview, IComparer nodeSorter)
{
MethodInvoker mi = delegate
{
treeview.TreeViewNodeSorter = nodeSorter;
treeview.Sort();
};
if (treeview.InvokeRequired)
{
treeview.Invoke(mi);
}
else
{
mi();
}
}
示例8: ClearTreeNodes
private void ClearTreeNodes(TreeView treeView)
{
if (this.InvokeRequired)
{
ClearTreeNodesDelegate d = new ClearTreeNodesDelegate(ClearTreeNodes);
treeView.Invoke(d, treeView);
}
else
{
treeView.Nodes.Clear();
}
}
示例9: ImportDataCard
private void ImportDataCard(string datacardPath, string initializeString, TreeView treeView)
{
_treeView = treeView;
Task.Run(() =>
{
_updateStatusAction(CurrentState, "Starting Import");
ApplicationDataModels = _dataProvider.Import(datacardPath, initializeString);
if (ApplicationDataModels == null || ApplicationDataModels.Count == 0)
{
MessageBox.Show(@"Not supported data format.");
CurrentState = State.StateIdle;
_updateStatusAction(CurrentState, "Done");
return;
}
_admIndex = 0;
for (; _admIndex < ApplicationDataModels.Count; _admIndex++)
{
var applicationDataModel = ApplicationDataModels[_admIndex];
applicationDataModel.Documents.LoggedData.SelectMany(x => x.OperationData.ToList()).ToList();
var parentNode = (TreeNode)_treeView.Invoke(new Func<TreeNode>(() => treeView.Nodes.Add("ApplicationDataModel")));
AddNode(applicationDataModel, parentNode);
}
CurrentState = State.StateIdle;
_updateStatusAction(CurrentState, "Done");
});
}
示例10: PopulateChildTree
public void PopulateChildTree(TreeView tree,TestTreeNodeFacade facade)
{
foreach(TreeTestDomain td in this.list)
{
UnitTreeNode node = this.factory.CreateUnitTreeNode(
td.TestTree.ParentNode.Name,
TestNodeType.Populator,
td.Identifier,
td.TestTree.ParentNode.Identifier
);
tree.Invoke(new AddNodeDelegate(tree.Nodes.Add),new Object[]{node});
td.PopulateChildTree(node,facade);
}
}
示例11: ConnectCompleted
static void ConnectCompleted(SSBIServer serv, Server srv, TreeView tv, TreeNode tn, bool success, string msg)
{
if (tv.InvokeRequired) {
tv.Invoke(new ConnectCompletedDelegate(ConnectCompleted), new object[] { serv, srv, tv, tn, success, msg });
}
else {
try {
if (success) {
serv.HasLoggedIn = true;
serv.SMOServer = srv;
serv.IsTryingToConnect = false;
tn.Tag = serv;
if (tn == tv.SelectedNode) {
tn.Expand();
}
}
else {
MessageBox.Show(msg);
}
}
catch (FailedOperationException fe) {
smo.ShowException(fe);
}
catch (Exception e) {
smo.ShowException(e);
}
finally {
//connNode = null;
tn.ForeColor = Color.Black;
//toolStripStatusLabel1.Text = "Ready!";
serv.IsTryingToConnect = false;
tn.Tag = serv;
tn.Text = serv.Name;
}
}
}
示例12: _GetNodesFromFuncAndPostToTreeView
// Dont call this one!!
private void _GetNodesFromFuncAndPostToTreeView(List<string> exts, TreeView tv)
{
TreeNode tr = null;
ParameterizedThreadStart starter = new ParameterizedThreadStart(obj => PopulateRootTreeFiles(exts, ref tr));
Thread process = new Thread(starter);
process.Start();
process.Join();
tv.Invoke(new Action<TreeNode, TreeView>(InsertNodeIntoTree), new object[] {tr, tv});
}
示例13: ClearTreeViewNodes
public void ClearTreeViewNodes(TreeView tv)
{
if (tv.InvokeRequired)
{
tv.Invoke(new Action<TreeView>(ClearTreeViewNodes), new object[] {tv});
}
else
{
tv.Nodes.Clear();
}
}
示例14: DeleteTreeRootNode
private void DeleteTreeRootNode(TreeView treeView, TreeNode tNode)
{
if (this.InvokeRequired)
{
DeleteTreeRootNodeDelegate d = new DeleteTreeRootNodeDelegate(DeleteTreeRootNode);
treeView.Invoke(d, treeView, tNode);
}
else
{
treeView.Nodes.Remove(tNode);
}
}
示例15: loadTreeViewWithDirectoriesAndFiles
public static void loadTreeViewWithDirectoriesAndFiles(TreeView tvTargetTreeView, String sDirectoryToProcess,
String sFileFilter, TextBox tbCurrentLoadedDirectory,
bool bShowFileSize, bool hideFiles)
{
try
{
if (tvTargetTreeView.InvokeRequired)
tvTargetTreeView.Invoke(
new EventHandler(
delegate
{
loadTreeViewWithDirectoriesAndFiles(tvTargetTreeView, sDirectoryToProcess,
sFileFilter, tbCurrentLoadedDirectory,
bShowFileSize, hideFiles);
}));
else
{
if (sDirectoryToProcess != "")
{
tvTargetTreeView.Visible = false;
tvTargetTreeView.Nodes.Clear();
String sPreviousDirectory = Path.GetFullPath(Path.Combine(sDirectoryToProcess, ".."));
if (Directory.Exists(sPreviousDirectory))
tvTargetTreeView.Nodes.Add(newTreeNode("..", sPreviousDirectory, 2, sPreviousDirectory));
foreach (String sDirectory in Directory.GetDirectories(sDirectoryToProcess))
{
tvTargetTreeView.Nodes.Add(newTreeNode(Path.GetFileName(sDirectory), sDirectory, 0,
sDirectory));
}
foreach (String sFile in Directory.GetFiles(sDirectoryToProcess, sFileFilter))
{
if (hideFiles)
{
var newNode = newTreeNode(Path.GetFileName(sFile), null, 1, null);
newNode.ForeColor = Color.Gray;
tvTargetTreeView.Nodes.Add(newNode);
}
else
{
if (bShowFileSize)
tvTargetTreeView.Nodes.Add(
newTreeNode(
String.Format("{0} : {1}k", Path.GetFileName(sFile),
Files.getFileSize(Path.Combine(sDirectoryToProcess, sFile)) / 1024),
sFile, 1, sFile));
else
tvTargetTreeView.Nodes.Add(newTreeNode(Path.GetFileName(sFile), sFile, 1, sFile));
}
}
tvTargetTreeView.Visible = true;
// if (null != lCurrentLoadedDirectory)
// lCurrentLoadedDirectory.Text = Path.GetFileName(sDirectoryToProcess);
}
else
PublicDI.log.error(
"in loadTreeViewWithDirectoriesAndFiles, sDirectoryToProcess != \"\", this value must be provided");
}
}
catch (Exception ex)
{
PublicDI.log.error("in loadTreeViewWithDirectoriesAndFiles: {0}", ex.Message);
}
}