在网格中,我必须仅在同一列中选择多个单元格。不允许用户从差异列中选择单元格。
我试过下面的代码。
Private Sub grdTransactions_InitializeLayout(ByVal sender As Object, _
ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) _
Handles grdTransactions.InitializeLayout
e.Layout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.CellSelect
End Sub
Private Sub grdTransactions_AfterSelectChange(sender As Object, _
e As AfterSelectChangeEventArgs) Handles grdTransactions.AfterSelectChange
Me.grdTransactions.DisplayLayout.Override.SelectTypeCell = UltraWinGrid.SelectType.Single
Me.grdTransactions.DisplayLayout.Override.SelectTypeCol = UltraWinGrid.SelectType.Single
Me.grdTransactions.DisplayLayout.Bands(0).Override.SelectTypeCell = UltraWinGrid.SelectType.Extended
Me.grdTransactions.DisplayLayout.Bands(0).Override.SelectTypeCol = UltraWinGrid.SelectType.Single
Me.grdTransactions.DisplayLayout.Bands(0).Override.MultiCellSelectionMode = MultiCellSelectionMode.Default
Me.grdTransactions.DisplayLayout.Bands(0).Override.MaxSelectedCells = 100
End Sub
以上代码允许从差异列中选择单元格。告诉我我哪里错了?
答案 0 :(得分:2)
如果您使用的是ultraGrid1_BeforeSelectChange()事件,也许可以采用一种方法来解决此任务。例如:
private void ultraGrid1_BeforeSelectChange(object sender, Infragistics.Win.UltraWinGrid.BeforeSelectChangeEventArgs e)
{
if (e.NewSelections.Cells.OfType<UltraGridCell>().First().Column.Key != e.NewSelections.Cells.OfType<UltraGridCell>().Last().Column.Key)
{
e.Cancel = true;
}
}