将 Infragistics UltraWinGrid 的特定列设置为只读

发布于 2024-09-02 06:13:32 字数 1223 浏览 9 评论 0原文

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

也就是说,网格中有 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

问题是,如果我单击禁用/只读行,则新添加的行也会被禁用,这是我不希望的。

I am stuck in a situation where I need to disable a few columns in each row, except for the newly added row.

That is, I have 10 columns in the grid and the first 3 columns are databound and come from the database as disabled or read-only. The rest are editable.

If I add a new row, then all the columns of the new row must be enabled until it is saved.

I don't have any DataKey or primary key for my existing row or the new row. I have to check for some boolean value like IsNewRow.

In my current scenario I am using this code block:

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

The problem is that if I click on disabled/read-only rows, then newly added rows also get disabled, which I don't want.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

子栖 2024-09-09 06:13:32

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

I am fighting with a similar problem in C#, so this is fishing in the dark... Is it possible, in your case, to add an IgnoreRowColActivation = true statement to keep the rows from reverting?

恰似旧人归 2024-09-09 06:13:32

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

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

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

设置第 1 列和第 1 列2 直接

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

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

This examples create read only columns for the interface a customer uses

Example for a row with three columns. Set two columns as readonly and the third as editable to the user.

the three columns defined in the designer:
System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;

set column 1 & 2 directly

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

You can still update all columns in the source code. The customer will only be able to edit the third column.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文