Select UltraGrid 的多行
Select multiple Rows with UltraGrid
我是使用 UltraGrid 的 Infragistics 新手。
我正在尝试使用复选框列 select 多行(或者如果有其他想法)
我有一个用于 DataGridView 的代码 select 多行并将其插入到列表中,而不是尝试删除或对 select 编辑的项目进行编码。
//get the selected item
List<DataGridViewRow> selectedRows = (from row in Detail_shanuDGV.Rows.Cast<DataGridViewRow>()
where Convert.ToBoolean(row.Cells["checkBoxColumn1"].Value) == true
select row).ToList();
但是当我尝试像这样将此代码与 UltraGrid 一起使用时
List<UltraGrid> selectedRows = (from row in ultraGrid1.Rows.Cast<UltraGrid>()
where Convert.ToBoolean(row.Cells["caption"].Value) == true
select row).ToList();
它给我这个错误
'UltraGrid' does not contain a definition for 'Cells' and no extension method 'Cells' accepting a first argument of type 'UltraGrid' could be found
So if theres another idea or how to find solution to solve this error.
By the way I am using hierarchical UltraGrid with checkbox column, in my UltraGrid I have Master/Details data
您应该转换为 UltraGridRow 而不是 UltraGrid
List<UltraGridRow> selectedRows = (from row in ultraGrid1.Rows.Cast<UltraGridRow>
where Convert.ToBoolean(row.Cells["caption"].Value) == true
select row).ToList();
此外,您可能需要对这些行进行另一级别的过滤。例如,不清楚列 Caption 的复选框是在网格的母版上还是在网格的详细信息窗格中。此外,如果您有 GroupBy 显示选项,那么您还需要添加另一个条件以仅过滤所需的行
例如,假设您要应用此逻辑但仅应用详细信息窗格中的行。在 Infragistcs 术语中,第二个窗格称为 Band,每一行都有一个 属性 表示它所属的 Band。 Band 有一个 属性 索引,所以你得到
List<UltraGridRow> selectedRows = (from row in ultraGrid1.Rows.Cast<UltraGridRow>
where row.Band.Index == 1 &&
Convert.ToBoolean(row.Cells["caption"].Value) == true
select row).ToList();
请注意,您首先检查 Band 索引,并且仅当此行位于第二个 band 上时才检查单元格值(因为如果第一个 band 中没有 "caption" 列,您将获得 NRE)
我是使用 UltraGrid 的 Infragistics 新手。
我正在尝试使用复选框列 select 多行(或者如果有其他想法)
我有一个用于 DataGridView 的代码 select 多行并将其插入到列表中,而不是尝试删除或对 select 编辑的项目进行编码。
//get the selected item
List<DataGridViewRow> selectedRows = (from row in Detail_shanuDGV.Rows.Cast<DataGridViewRow>()
where Convert.ToBoolean(row.Cells["checkBoxColumn1"].Value) == true
select row).ToList();
但是当我尝试像这样将此代码与 UltraGrid 一起使用时
List<UltraGrid> selectedRows = (from row in ultraGrid1.Rows.Cast<UltraGrid>()
where Convert.ToBoolean(row.Cells["caption"].Value) == true
select row).ToList();
它给我这个错误
'UltraGrid' does not contain a definition for 'Cells' and no extension method 'Cells' accepting a first argument of type 'UltraGrid' could be found So if theres another idea or how to find solution to solve this error. By the way I am using hierarchical UltraGrid with checkbox column, in my UltraGrid I have Master/Details data
您应该转换为 UltraGridRow 而不是 UltraGrid
List<UltraGridRow> selectedRows = (from row in ultraGrid1.Rows.Cast<UltraGridRow>
where Convert.ToBoolean(row.Cells["caption"].Value) == true
select row).ToList();
此外,您可能需要对这些行进行另一级别的过滤。例如,不清楚列 Caption 的复选框是在网格的母版上还是在网格的详细信息窗格中。此外,如果您有 GroupBy 显示选项,那么您还需要添加另一个条件以仅过滤所需的行
例如,假设您要应用此逻辑但仅应用详细信息窗格中的行。在 Infragistcs 术语中,第二个窗格称为 Band,每一行都有一个 属性 表示它所属的 Band。 Band 有一个 属性 索引,所以你得到
List<UltraGridRow> selectedRows = (from row in ultraGrid1.Rows.Cast<UltraGridRow>
where row.Band.Index == 1 &&
Convert.ToBoolean(row.Cells["caption"].Value) == true
select row).ToList();
请注意,您首先检查 Band 索引,并且仅当此行位于第二个 band 上时才检查单元格值(因为如果第一个 band 中没有 "caption" 列,您将获得 NRE)