无法在运行时在数据表中添加复选框 C# wpf

发布于 2024-08-06 18:29:04 字数 3268 浏览 3 评论 0原文

私有无效SetAppData() { ArrayList alDiscoveredNodes = this.DiscoverNetworNodes();

        //initializeViewDataTable will add colums to ViewDataTable that will be shown on View
        initializeViewDataTable(alDiscoveredNodes);

        Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (setPopulateTree)delegate(ArrayList alNodes)
        {
            this.PopulateTreeView(alNodes);
            //this.DrawChart(dtProtocolDetails);                

        }, alDiscoveredNodes);

        //GetNetworkComputers objGetNetworkComputers = new GetNetworkComputers(100);
        DataTable dtProtocolInfo = objCProtocols.ScanForProtocols(alDiscoveredNodes);

        //Calling populateViewDataTable will take dtProtocolInfo by reference and then it will create 
        // another datatable that is for viewsing purpose
        populateViewDataTable(ref dtProtocolInfo);

        Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (setData)delegate(DataTable dtProtocolDetails)
        {
            dataGridRunningProtocols.DataContext = dtProtocolDetails;


        }, dtProtocolInfo);


        Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (setChartData)delegate(ref DataTable dtProtocolDetails)
        {

            try
            {
                DrawChart(dtProtocolDetails);                   

            }
            catch (Exception exc)
            {

                MessageBox.Show(exc.InnerException.ToString());
            }
        }, dtProtocolInfo);


        Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (setChartTitle)delegate(string strTitle)
        {
            mainChart.Title = "Protocol Availability Over Network";


        }, "");
        //pThread.Abort();
       // splash.Close(new TimeSpan(00, 00, 3));

    }

    /// <summary>
    /// It will add Columns to DataTable at run time according to columns defined in
    /// ProtocolConfigration Array
    /// </summary>
    private void initializeViewDataTable(ArrayList alHosts)
    {
        DataColumn dt = null;
        viewDataTable = new DataTable();
        viewDataTable.Columns.Add("Host");
        for (int i = 0; i < ProtocolConfiguration.STR_ARR_PROTOCOLS.Length; i++)
        {
            //viewDataTable.Columns.Add(ProtocolConfiguration.STR_ARR_PROTOCOLS[i][1] + " (" + ProtocolConfiguration.STR_ARR_PROTOCOLS[i][0] + " )", System.Type.GetType("System.Boolean"));                
            dt = new DataColumn(ProtocolConfiguration.STR_ARR_PROTOCOLS[i][1] + " (" + ProtocolConfiguration.STR_ARR_PROTOCOLS[i][0] + " )");
            //dt.DataType = typeof(System.Windows.Controls.CheckBox);
            dt.DataType = typeof(bool);
            viewDataTable.Columns.Add(dt);                
        }

       foreach (string strHost in alHosts)
       {


           //CheckBox cbTemp = new CheckBox();
           //cbTemp.IsChecked = true;
           viewDataTable.Rows.Add(strHost, false);
       }
    }

我想通过数据表添加与数据网格中某些用户相对的复选框。 就像如果用户没有在他的计算机上运行 FTP 协议一样,我放置了一个未选中的复选框,以表明该用户没有在他的计算机上运行 FTP 协议。请提供任何帮助

private void SetAppData()
{
ArrayList alDiscoveredNodes = this.DiscoverNetworNodes();

        //initializeViewDataTable will add colums to ViewDataTable that will be shown on View
        initializeViewDataTable(alDiscoveredNodes);

        Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (setPopulateTree)delegate(ArrayList alNodes)
        {
            this.PopulateTreeView(alNodes);
            //this.DrawChart(dtProtocolDetails);                

        }, alDiscoveredNodes);

        //GetNetworkComputers objGetNetworkComputers = new GetNetworkComputers(100);
        DataTable dtProtocolInfo = objCProtocols.ScanForProtocols(alDiscoveredNodes);

        //Calling populateViewDataTable will take dtProtocolInfo by reference and then it will create 
        // another datatable that is for viewsing purpose
        populateViewDataTable(ref dtProtocolInfo);

        Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (setData)delegate(DataTable dtProtocolDetails)
        {
            dataGridRunningProtocols.DataContext = dtProtocolDetails;


        }, dtProtocolInfo);


        Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (setChartData)delegate(ref DataTable dtProtocolDetails)
        {

            try
            {
                DrawChart(dtProtocolDetails);                   

            }
            catch (Exception exc)
            {

                MessageBox.Show(exc.InnerException.ToString());
            }
        }, dtProtocolInfo);


        Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (setChartTitle)delegate(string strTitle)
        {
            mainChart.Title = "Protocol Availability Over Network";


        }, "");
        //pThread.Abort();
       // splash.Close(new TimeSpan(00, 00, 3));

    }

    /// <summary>
    /// It will add Columns to DataTable at run time according to columns defined in
    /// ProtocolConfigration Array
    /// </summary>
    private void initializeViewDataTable(ArrayList alHosts)
    {
        DataColumn dt = null;
        viewDataTable = new DataTable();
        viewDataTable.Columns.Add("Host");
        for (int i = 0; i < ProtocolConfiguration.STR_ARR_PROTOCOLS.Length; i++)
        {
            //viewDataTable.Columns.Add(ProtocolConfiguration.STR_ARR_PROTOCOLS[i][1] + " (" + ProtocolConfiguration.STR_ARR_PROTOCOLS[i][0] + " )", System.Type.GetType("System.Boolean"));                
            dt = new DataColumn(ProtocolConfiguration.STR_ARR_PROTOCOLS[i][1] + " (" + ProtocolConfiguration.STR_ARR_PROTOCOLS[i][0] + " )");
            //dt.DataType = typeof(System.Windows.Controls.CheckBox);
            dt.DataType = typeof(bool);
            viewDataTable.Columns.Add(dt);                
        }

       foreach (string strHost in alHosts)
       {


           //CheckBox cbTemp = new CheckBox();
           //cbTemp.IsChecked = true;
           viewDataTable.Rows.Add(strHost, false);
       }
    }

i want to add checkbox opposite to some users in data grid through data table.
Like if a user is not running FTP protocol on his computer I have tu place a checkbox that is un-checked to show that this user does not have FTP protocol running on his computer.. any help please

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

沫雨熙 2024-08-13 18:29:04
private void DrawChart() {

ArrayList ar= new ArrayList();
ar.Add("one");
    ar.Add("two");
    ar.Add("three");

        for (int i = 0; i <ar.count ; i++)
        {
                           addRecursiveLedgendAfterInit(ar[i], 50);
        }
    }
private void addRecursiveLedgendAfterInit(string legend,int legendvalue) {

        ICollection<KeyValuePair<String, int>> data = new Dictionary<String, int>();
        data.Add(new KeyValuePair<string, int>(legend, legendvalue));

            ColumnSeries mycolseries = new ColumnSeries
            {
                ItemsSource = data,

                Title = legend,
                IndependentValuePath = "Key",
                DependentValuePath = "Value",

            };

            mainChart.Series.Add(mycolseries);
    }
private void DrawChart() {

ArrayList ar= new ArrayList();
ar.Add("one");
    ar.Add("two");
    ar.Add("three");

        for (int i = 0; i <ar.count ; i++)
        {
                           addRecursiveLedgendAfterInit(ar[i], 50);
        }
    }
private void addRecursiveLedgendAfterInit(string legend,int legendvalue) {

        ICollection<KeyValuePair<String, int>> data = new Dictionary<String, int>();
        data.Add(new KeyValuePair<string, int>(legend, legendvalue));

            ColumnSeries mycolseries = new ColumnSeries
            {
                ItemsSource = data,

                Title = legend,
                IndependentValuePath = "Key",
                DependentValuePath = "Value",

            };

            mainChart.Series.Add(mycolseries);
    }
美人迟暮 2024-08-13 18:29:04

私有无效SetAppData()
{
ArrayList alDiscoveredNodes = this.DiscoverNetworNodes();

        //initializeViewDataTable will add colums to ViewDataTable that will be shown on View
        initializeViewDataTable(alDiscoveredNodes);

        Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (setPopulateTree)delegate(ArrayList alNodes)
        {
            this.PopulateTreeView(alNodes);
            //this.DrawChart(dtProtocolDetails);                

        }, alDiscoveredNodes);

        //GetNetworkComputers objGetNetworkComputers = new GetNetworkComputers(100);
        DataTable dtProtocolInfo = objCProtocols.ScanForProtocols(alDiscoveredNodes);

        //Calling populateViewDataTable will take dtProtocolInfo by reference and then it will create 
        // another datatable that is for viewsing purpose
        populateViewDataTable(ref dtProtocolInfo);

        Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (setData)delegate(DataTable dtProtocolDetails)
        {
            dataGridRunningProtocols.DataContext = dtProtocolDetails;


        }, dtProtocolInfo);


        Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (setChartData)delegate(ref DataTable dtProtocolDetails)
        {

            try
            {
                DrawChart(dtProtocolDetails);                   

            }
            catch (Exception exc)
            {

                MessageBox.Show(exc.InnerException.ToString());
            }
        }, dtProtocolInfo);


        Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (setChartTitle)delegate(string strTitle)
        {
            mainChart.Title = "Protocol Availability Over Network";


        }, "");
        //pThread.Abort();
       // splash.Close(new TimeSpan(00, 00, 3));

    }

    /// <summary>
    /// It will add Columns to DataTable at run time according to columns defined in
    /// ProtocolConfigration Array
    /// </summary>
    private void initializeViewDataTable(ArrayList alHosts)
    {
        DataColumn dt = null;
        viewDataTable = new DataTable();
        viewDataTable.Columns.Add("Host");
        for (int i = 0; i < ProtocolConfiguration.STR_ARR_PROTOCOLS.Length; i++)
        {
            //viewDataTable.Columns.Add(ProtocolConfiguration.STR_ARR_PROTOCOLS[i][1] + " (" + ProtocolConfiguration.STR_ARR_PROTOCOLS[i][0] + " )", System.Type.GetType("System.Boolean"));                
            dt = new DataColumn(ProtocolConfiguration.STR_ARR_PROTOCOLS[i][1] + " (" + ProtocolConfiguration.STR_ARR_PROTOCOLS[i][0] + " )");
            //dt.DataType = typeof(System.Windows.Controls.CheckBox);
            dt.DataType = typeof(bool);
            viewDataTable.Columns.Add(dt);                
        }

       foreach (string strHost in alHosts)
       {


           //CheckBox cbTemp = new CheckBox();
           //cbTemp.IsChecked = true;
           viewDataTable.Rows.Add(strHost, false);
       }
    }

我想通过数据表添加与数据网格中某些用户相对的复选框。
就像如果用户没有在他的计算机上运行 FTP 协议一样,我放置了一个未选中的复选框,以表明该用户没有在他的计算机上运行 FTP 协议。请提供任何帮助

private void SetAppData()
{
ArrayList alDiscoveredNodes = this.DiscoverNetworNodes();

        //initializeViewDataTable will add colums to ViewDataTable that will be shown on View
        initializeViewDataTable(alDiscoveredNodes);

        Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (setPopulateTree)delegate(ArrayList alNodes)
        {
            this.PopulateTreeView(alNodes);
            //this.DrawChart(dtProtocolDetails);                

        }, alDiscoveredNodes);

        //GetNetworkComputers objGetNetworkComputers = new GetNetworkComputers(100);
        DataTable dtProtocolInfo = objCProtocols.ScanForProtocols(alDiscoveredNodes);

        //Calling populateViewDataTable will take dtProtocolInfo by reference and then it will create 
        // another datatable that is for viewsing purpose
        populateViewDataTable(ref dtProtocolInfo);

        Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (setData)delegate(DataTable dtProtocolDetails)
        {
            dataGridRunningProtocols.DataContext = dtProtocolDetails;


        }, dtProtocolInfo);


        Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (setChartData)delegate(ref DataTable dtProtocolDetails)
        {

            try
            {
                DrawChart(dtProtocolDetails);                   

            }
            catch (Exception exc)
            {

                MessageBox.Show(exc.InnerException.ToString());
            }
        }, dtProtocolInfo);


        Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (setChartTitle)delegate(string strTitle)
        {
            mainChart.Title = "Protocol Availability Over Network";


        }, "");
        //pThread.Abort();
       // splash.Close(new TimeSpan(00, 00, 3));

    }

    /// <summary>
    /// It will add Columns to DataTable at run time according to columns defined in
    /// ProtocolConfigration Array
    /// </summary>
    private void initializeViewDataTable(ArrayList alHosts)
    {
        DataColumn dt = null;
        viewDataTable = new DataTable();
        viewDataTable.Columns.Add("Host");
        for (int i = 0; i < ProtocolConfiguration.STR_ARR_PROTOCOLS.Length; i++)
        {
            //viewDataTable.Columns.Add(ProtocolConfiguration.STR_ARR_PROTOCOLS[i][1] + " (" + ProtocolConfiguration.STR_ARR_PROTOCOLS[i][0] + " )", System.Type.GetType("System.Boolean"));                
            dt = new DataColumn(ProtocolConfiguration.STR_ARR_PROTOCOLS[i][1] + " (" + ProtocolConfiguration.STR_ARR_PROTOCOLS[i][0] + " )");
            //dt.DataType = typeof(System.Windows.Controls.CheckBox);
            dt.DataType = typeof(bool);
            viewDataTable.Columns.Add(dt);                
        }

       foreach (string strHost in alHosts)
       {


           //CheckBox cbTemp = new CheckBox();
           //cbTemp.IsChecked = true;
           viewDataTable.Rows.Add(strHost, false);
       }
    }

i want to add checkbox opposite to some users in data grid through data table.
Like if a user is not running FTP protocol on his computer I have tu place a checkbox that is un-checked to show that this user does not have FTP protocol running on his computer.. any help please

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文