运行时不能在datatable中添加复选框C#wpf

运行时不能在datatable中添加复选框C#wpf,c#,wpf,datatable,checkbox,runtime,C#,Wpf,Datatable,Checkbox,Runtime,私有void SetAppData() { ArrayList alDiscoveredNodes=this.DiscoverNetworNodes() //initializeViewDataTable将向ViewDataTable添加列,该列将显示在视图中 初始化eView数据表(alDiscoveredNodes); Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.

私有void SetAppData() { ArrayList alDiscoveredNodes=this.DiscoverNetworNodes()

//initializeViewDataTable将向ViewDataTable添加列,该列将显示在视图中
初始化eView数据表(alDiscoveredNodes);
Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,(setPopulateTree)委托(ArrayList alNodes)
{
此.PopulateTreeView(alNodes);
//这是一张图纸(DTD);
},alDiscoveredNodes);
//GetNetworkComputers objGetNetworkComputers=新的GetNetworkComputers(100);
DataTable dtProtocolInfo=objCProtocols.ScanForProtocols(alDiscoveredNodes);
//调用populateViewDataTable将引用dtProtocolInfo,然后创建
//另一个用于查看的数据表
populateViewDataTable(参考dtProtocolInfo);
Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,(setData)委托(DataTable dtProtocolDetails)
{
dataGridRunningProtocols.DataContext=dtProtocolDetails;
},dtProtocolInfo);
Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,(setChartData)委托(参考数据表dtProtocolDetails)
{
尝试
{
绘图图(DTD);
}
捕获(异常exc)
{
Show(exc.InnerException.ToString());
}
},dtProtocolInfo);
Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,(setChartTitle)委托(字符串strTitle)
{
mainChart.Title=“网络上的协议可用性”;
}, "");
//pThread.Abort();
//splash.Close(新的时间跨度(00,00,3));
}
/// 
///它将在运行时根据中定义的列向DataTable添加列
///协议配置阵列
/// 
私有void initializeViewDataTable(ArrayList alHosts)
{
DataColumn dt=null;
viewDataTable=新数据表();
viewDataTable.Columns.Add(“主机”);
对于(int i=0;i
我想通过数据表在数据网格中的一些用户的对面添加复选框。 比如,如果一个用户没有在他的计算机上运行FTP协议,我必须选中一个未选中的复选框,以表明该用户没有在他的计算机上运行FTP协议。。请提供任何帮助

private void SetAppData()
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);
    }
{ ArrayList alDiscoveredNodes=this.DiscoverNetworNodes()

//initializeViewDataTable将向ViewDataTable添加列,该列将显示在视图中
初始化eView数据表(alDiscoveredNodes);
Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,(setPopulateTree)委托(ArrayList alNodes)
{
此.PopulateTreeView(alNodes);
//这是一张图纸(DTD);
},alDiscoveredNodes);
//GetNetworkComputers objGetNetworkComputers=新的GetNetworkComputers(100);
DataTable dtProtocolInfo=objCProtocols.ScanForProtocols(alDiscoveredNodes);
//调用populateViewDataTable将引用dtProtocolInfo,然后创建
//另一个用于查看的数据表
populateViewDataTable(参考dtProtocolInfo);
Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,(setData)委托(DataTable dtProtocolDetails)
{
dataGridRunningProtocols.DataContext=dtProtocolDetails;
},dtProtocolInfo);
Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,(setChartData)委托(参考数据表dtProtocolDetails)
{
尝试
{
绘图图(DTD);
}
捕获(异常exc)
{
Show(exc.InnerException.ToString());
}
},dtProtocolInfo);
Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,(setChartTitle)委托(字符串strTitle)
{
mainChart.Title=“网络上的协议可用性”;
}, "");
//pThread.Abort();
//splash.Close(新的时间跨度(00,00,3));
}
/// 
///它将在运行时根据中定义的列向DataTable添加列
///协议配置阵列
/// 
私有void initializeViewDataTable(ArrayList alHosts)
{
DataColumn dt=null;
viewDataTable=新数据表();
viewDataTable.Columns.Add(“主机”);
对于(int i=0;i        //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);
       }
    }
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);
    }