代码之家  ›  专栏  ›  技术社区  ›  user240141

使Infrastics UltraWinGrid的特定列为只读

  •  1
  • user240141  · 技术社区  · 16 年前

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

    我的现有行或新行没有任何数据键或主键。我必须检查一些布尔值,比如 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
    

    问题是,如果我单击disabled/read-only行,那么新添加的行也会被禁用,这是我不想要的。

    2 回复  |  直到 12 年前
        1
  •  0
  •   Van    16 年前

    我正在与C#中的一个类似问题作斗争,所以这是在黑暗中钓鱼。。。在您的例子中,是否可以添加IgnoreRowColActivation=true语句来防止行还原?

        2
  •  0
  •   user4560901 user4560901    11 年前

    此示例为客户使用的接口创建只读列

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

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

    设置列1&2直接

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

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