【问题标题】:Making Infragistics UltraWinGrid's Specific Columns Read-only将 Infragistics UltraWinGrid 的特定列设为只读
【发布时间】:2010-05-20 15:09:26
【问题描述】:

我陷入了需要禁用每行中的几列的情况,除了新添加的行。

也就是说,我在网格中有 10 列,前 3 列是数据绑定的,并且来自数据库作为禁用或只读。其余的都是可编辑的。

如果我添加一个新行,那么新行的所有列都必须启用,直到它被保存。

我的现有行或新行没有任何 DataKey 或主键。我必须检查一些布尔值,例如 IsNewRow

在我目前的情况下,我正在使用这个代码块:

Private Sub dgTimeSheet_InitializeRow(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeRowEventArgs) Handles dgTimeSheet.InitializeRow

    ''if either column key is Project, Class or Milestone

    '' Activation.NoEdit = Disable and Activation.AllowEdit = Enable

    Dim index As Integer = e.Row.Index

     If e.Row.IsAddRow Then

        dgTimeSheet.Rows(index).Cells(PROJECT).Activation = Activation.AllowEdit

        dgTimeSheet.Rows(index).Cells(SERVICE_ISSUE_CLASS).Activation = Activation.AllowEdit

        dgTimeSheet.Rows(index).Cells(MILESTONE).Activation = Activation.AllowEdit

     Else

        dgTimeSheet.Rows(index).Cells(PROJECT).Activation = Activation.NoEdit

        dgTimeSheet.Rows(index).Cells(SERVICE_ISSUE_CLASS).Activation = Activation.NoEdit

        dgTimeSheet.Rows(index).Cells(MILESTONE).Activation = Activation.NoEdit


    End If

    CheckRows()

End Sub

问题是,如果我点击禁用/只读行,那么新添加的行也会被禁用,这是我不想要的。

【问题讨论】:

    标签: vb.net infragistics ultrawingrid


    【解决方案1】:

    我正在与 C# 中的类似问题作斗争,所以这是在黑暗中钓鱼...在您的情况下,是否可以添加 IgnoreRowColActivation = true 语句以防止行恢复?

    【讨论】:

      【解决方案2】:

      此示例为客户使用的界面创建只读列

      一行三列的示例。将两列设置为只读,第三列设置为用户可编辑。

      设计器中定义的三列: System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn1; System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn2; System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;

      直接设置第 1 列和第 2 列

      this.dataGridViewTextBoxColumn1.ReadOnly = true
      this.dataGridViewTextBoxColumn2.ReadOnly = true
      

      您仍然可以更新源代码中的所有列。客户将只能编辑第三列。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-02-04
        • 1970-01-01
        • 1970-01-01
        • 2010-11-15
        • 1970-01-01
        • 2010-12-11
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多