无法使用 C# 在 Telerik Grid 中选择多个复选框

发布于 2025-01-03 13:38:00 字数 1081 浏览 1 评论 0原文

我在我的应用程序中使用 Telerik 网格。我在网格的第一列插入了 GridViewCheckBoxColumn。复选框创建成功,但我无法选中多个复选框。我只能选中单个复选框。

如何勾选多个复选框?

 And also i want to know that checked row counts in the telerik gridview because i am using collection to bind the data in the GridView. In that collection How shall i get the selected rows? 

请告诉我一些解决这些问题的建议

这是我的代码

//AvailablePacks 正在获取网格视图中的所有行

 foreach (var pack in AvailablePacks)    
 {
       if (SelectedPack != null)
       {
            var cachedPack = AvailablePacks.FirstOrDefault(z => z.Casepack.CasePackId == pack.Casepack.CasePackId);    
            ((IList<CasePackPivotRow>)AvailablePacks).Add(SelectedPack );    
            this.SelectedPacks.Remove(SelectedPack );
       }
 } 

这是我用于在网格视图中创建复选框的 XAML 代码:

<telerik:GridViewCheckBoxColumn Header="" 
    Width="15" 
    EditTriggers="CellClick" 
    AutoSelectOnEdit="True" 
    DataMemberBinding="{Binding Selection, Mode=TwoWay}"/>

我必须在网格中选择多个复选框吗?

提前致谢。

I am using Telerik grid in my application. I inserted a GridViewCheckBoxColumn at first column of the grid. The check boxes created successfully but i am not able to check multiple check boxes. I am able to check single checkbox only.

How can i check multiple checkboxes?

 And also i want to know that checked row counts in the telerik gridview because i am using collection to bind the data in the GridView. In that collection How shall i get the selected rows? 

Please tell me some suggestion to solve these problems

Here is my code

// AvailablePacks is getting all the rows in the grid view

 foreach (var pack in AvailablePacks)    
 {
       if (SelectedPack != null)
       {
            var cachedPack = AvailablePacks.FirstOrDefault(z => z.Casepack.CasePackId == pack.Casepack.CasePackId);    
            ((IList<CasePackPivotRow>)AvailablePacks).Add(SelectedPack );    
            this.SelectedPacks.Remove(SelectedPack );
       }
 } 

And here is my XAML code for creating check box in gridview:

<telerik:GridViewCheckBoxColumn Header="" 
    Width="15" 
    EditTriggers="CellClick" 
    AutoSelectOnEdit="True" 
    DataMemberBinding="{Binding Selection, Mode=TwoWay}"/>

What i have to select multiple checkboxes in the grid?

Thanks in Advance.

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

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

发布评论

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

评论(1

无声情话 2025-01-10 13:38:00

泰勒里克 说:
解决方案

为了实现所需的要求,首先订阅 ValueChanged 事件,然后在 ValueChanged 事件处理程序中执行以下代码片段:

 void radGridView1_ValueChanged(object sender, EventArgs e) 
 { 

  RadCheckBoxEditor editor = sender as RadCheckBoxEditor; 

  if (editor != null && (bool)editor.Value == true) 

   { 

    this.radGridView1.GridElement.BeginUpdate(); 

    foreach (GridViewDataRowInfo row in this.radGridView1.Rows) 

    { 

        if (row != this.radGridView1.CurrentRow) 

        { 

            row.Cells["Bool"].Value = false; 

        } 

    } 

    this.radGridView1.GridElement.EndUpdate(); 

} 

}

telerik said :
SOLUTION

In order to implement the desired requirement, first subscribe to the ValueChanged event and then execute the following code snippet in the ValueChanged event handler:

 void radGridView1_ValueChanged(object sender, EventArgs e) 
 { 

  RadCheckBoxEditor editor = sender as RadCheckBoxEditor; 

  if (editor != null && (bool)editor.Value == true) 

   { 

    this.radGridView1.GridElement.BeginUpdate(); 

    foreach (GridViewDataRowInfo row in this.radGridView1.Rows) 

    { 

        if (row != this.radGridView1.CurrentRow) 

        { 

            row.Cells["Bool"].Value = false; 

        } 

    } 

    this.radGridView1.GridElement.EndUpdate(); 

} 

}

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