无法使用复选框列在infragistics ultrawingrid上选择多个行 [英] Unable to select multiple rows on infragistics ultrawingrid with a check box column

查看:1631
本文介绍了无法使用复选框列在infragistics ultrawingrid上选择多个行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面的代码,成功地添加了一个复选框列到ultrawingrid,我的问题是,当我通过选中一个复选框选择列选择行的选择行的计数的ultrawingrid没有更新,它仍然显示计数为零,也想知道如何启用多选择框选择,即选择多个行...

I am having below code that successfully adds a check box column to the ultrawingrid, my problem is that when I make a selection by checking a check box on the Select column the count of selected rows of ultrawingrid is not updated and it still shows the count as zero, and also I want to know how to enable multi checkbox selection i.e multiple rows selected...

下面是代码...

private void grdPayVis_InitializeLayout(object sender,InitializeLayoutEventArgs e) 
 var gridBand = grdPayVis.DisplayLayout.Bands[0]; 
    if(!gridBand.Columns.Exists("Select"))
    gridBand.Columns.Add("Select", "Select");
gridBand.Columns["Select"].Header.VisiblePosition = 0; 
gridBand.Columns["Select"].Hidden = false; 
gridBand.Columns["Select"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox; 
gridBand.Columns["Select"].AutoSizeMode = ColumnAutoSizeMode.AllRowsInBand; 
gridBand.Columns["Select"].CellClickAction = CellClickAction.Edit; 

}

推荐答案

我不知道你实际上是想实现。当您在选择列中将 CellClickAction 设置为编辑,并点击此列中的任何单元格时,网格将选择该单元格,行。网格具有 Selected 属性,它公开了三个集合 - 行,列和单元格。在您的情况下,您要更改所选的单元格,不要更改所选的行集合。如果您需要选择行,则需要在选择列中将 CellClickAction 设置为 RowSelect 。如果您需要同时更改选择列的复选框状态,您可以像下面这样处理网格的 AfterSelectChange 事件:

I am not sure what you actually is trying to achieve. When you set CellClickAction in your Select column to Edit, and you click on any cell in this column the grid will select the cell and not the row. Grid has Selected property which exposes three collections - rows, columns and cells. In your case you are changing the selected cells and do not change the selected rows collection. If you need to select rows you need to set CellClickAction in your Select column to RowSelect. If you need in the same time to shange the checkbox state of the Select column you may handle AfterSelectChange event of the grid like this:

private void grdPayVis_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
{
    if (e.Type == typeof(UltraGridRow))
    {
        foreach (UltraGridRow row in this.grdPayVis.Selected.Rows)
        {
            row.Cells["Select"].Value = true; // Or some value appropriate to your scenario
        }

        this.grdPayVis.UpdateData();
    }   



默认情况下,网格允许您选择多个单元格,行或列。但是,当编辑模式下有单元格时,您不能选择任何其他单元格。因此,当您点击选择列中的任何单元格时,您已将 CellClickAction 设置为编辑,它会进入编辑模式,在退出编辑模式之前。

By default, the grid allows you to select many cells, rows or columns. However, when there is a cell in edit mode you cannot select any other cells. So again, as you have set CellClickAction to Edit when you click any cell in Select column it enters edit mode and no more cells could be selected before you exit edit mode.

这篇关于无法使用复选框列在infragistics ultrawingrid上选择多个行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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