使用UltraWinGrid在同一列中选择多个单元格



在网格中,我只能选择同一列中的多个单元格。不应允许用户从差异列中选择单元格。

我试过下面的代码。

  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

上面的代码允许从差异列中选择单元格。告诉我哪里错了?

也许解决此任务的一种可能方法是使用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;
        }
    }

相关内容

  • 没有找到相关文章

最新更新