DataGridItem引用和复选框检查dataGrid [英] DataGridItem reference and checkbox check in dataGrid

查看:67
本文介绍了DataGridItem引用和复选框检查dataGrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我正在处理名为dataGrid的RadGridView(telrik),在第一列我通过datatemplate添加了一个复选框



hello please i'm working on RadGridView(telrik) named "dataGrid" and in the first column i added a checkbox via datatemplate

<pre lang="c#">Telerik.Windows.Controls.GridViewDataColumn col = new Telerik.Windows.Controls.GridViewDataColumn();
                FrameworkElementFactory checkBox = new FrameworkElementFactory(typeof(CheckBox));
                checkBox.SetBinding(CheckBox.IsCheckedProperty, new Binding("Checkedcolumn"));
                DataTemplate template = new DataTemplate() { VisualTree = checkBox };
                template.Seal();
                col.CellTemplate = template; 
                dataGrid.Columns.Add(col);





它工作,我收集了一些项目作为datagrid:在以下代码中



and it work and i have collection of some items as the datagrid :in the following code

public ObservableCollection<T> SelectedData { get { return _selectedData; } set { _selectedData = value; } }



i想要在datagrid中检查SelectedData集合中存在的项目我试过这段代码而数据集是我将它绑定到的集合我的dataGrid


i want to check in datagrid the items which are existant in the SelectedData collection i tried this code and the Dataset is the collection that i bind it to my dataGrid

foreach(T item in SelectedData)
            {
                
                for (int i = 0; i < Dataset.Count;i++ )
                {
                   
                    if ((int)Dataset[i].GetPropertyValue("Id") == (int)item.GetPropertyValue("Id"))
                    {
                     
                        foreach (DataGridViewRow row in dataGrid.Items)
                      {
                         
                          ((DataGridViewCheckBoxCell)row.Cells[0]).Value = true;
                      }

                    }
                }
            }

但它不起作用我尝试使用DatagridItem类型,如foreach(DataGrid.Items中的DatagridItem行) )但DatagridItem给我无法找到错误甚至System.Web.UI.WebControls给我在Sstem.Web中不存在UI错误请帮助我,因为几乎在网络上的解决方案使用行和单元格是不能用RadGridview(我是男士telerik DataGrid)

but it doesnt work i tried with DatagridItem type like this foreach (DatagridItem row in dataGrid.Items) but DatagridItem give me "can not be found" error even System.Web.UI.WebControls give me "UI doesn't exist in Sstem.Web" error please help me because almost of solution on the web use Rows and Cells which are not avalable with RadGridview (i men telerik DataGrid)

推荐答案

这篇关于DataGridItem引用和复选框检查dataGrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆