zoukankan      html  css  js  c++  java
  • C#异步Tree

     private void Tree_AfterExpand(object sender, TreeViewEventArgs e)
            {
                int FileID = int.Parse(((ListItem)comboxFile.Items[comboxFile.SelectedIndex]).ID);
                BackgroundWorker bw = new BackgroundWorker();
                bw.DoWork += new DoWorkEventHandler(bw_DoWork);
                bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);

                object[] oArgs = new object[] { e.Node, FileID };
                bw.RunWorkerAsync(oArgs);
                bomTree.SelectedNode = e.Node;
            }

      private void bw_DoWork(object sender, DoWorkEventArgs e)

            {
                object[] oArgs = e.Argument as object[];
                TreeNode tn = oArgs[0as TreeNode;
                int FileID = int.Parse(oArgs[1].ToString());
                DataAccess da = new DataAccess();
                DataTable dtChildren = null;
                DataTable dgvlist = null;
                if (tn.Tag != null)
                {
                    dtChildren = new DataTable();
                    dtChildren = GetData();
                    dgvlist = new DataTable();
                    dgvlist =GetData(); 
                }
                else
                {
                    dtChildren = new DataTable();
                    dtChildren =da.SearchChildren(FileID, tn.Text + "%");
                }

                e.Result = new object[] { tn, dtChildren, dgvlist };
            }
     private void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
            {
                object[] oResult = e.Result as object[];
                TreeNode tNodeParent = oResult[0as TreeNode;
                DataTable dtChildren = oResult[1as DataTable;
                DataTable dgvlist = oResult[2as DataTable;
                ArrayList arr = new ArrayList();
                
               
                //dosomething

            } 

  • 相关阅读:
    MongoDB入门教程二[MongoDB Shell 简介与使用]
    MongoDB入门教程一[文档与集合]
    MongoDB图形化管理工具Toad Mac Edition
    在Mac上安装MongoDB
    第一个iOS程序:Hello iOS
    Xcode集成开发环境的安装
    搭建 Android 集成开发环境
    Mac下如何安装JDK
    sdoi 2009 HH去散步 矩阵乘
    noip2010 引水入城 bfs+贪心
  • 原文地址:https://www.cnblogs.com/keepsilence/p/2465929.html
Copyright © 2011-2022 走看看