0

我目前有一个绑定到从 XML 文件读取的 DataSet 的 DataGridView。

填充 DataGridView 就好了;最后一列是我希望用户单击以提交对行的更改的按钮。

我能够轻松找到哪些行是脏的,但是,我很难找到脏行中的哪些单元格本身是脏的。

我遍历了脏行中的每个单元格,但它们并没有显示为脏的。

任何想法表示赞赏!

if ( this.inventoryGridView.Columns[e.ColumnIndex].Name == "itemCheckedIn" )
        {
            // Give the user a visual indicator the cells are "locked"/readonly by changing the background color
            this.inventoryGridView.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.LightGray;

            // Check if any changes have been made to the row that was checked in
            if ( this.inventoryGridView.IsCurrentRowDirty )
            {
                foreach ( DataGridViewCell dirtyBoy in this.inventoryGridView.CurrentRow.Cells )
                {
                    // Is he dirty?
                }
            }

            // No changes were made to the row that was check in; let's log the check in
            else
            {
                // Log the check in time
            }
4

1 回答 1

0

你可以试试这个:

  1. 将隐藏列添加到您的 gridView
  2. 在将任何值更改为行中的单元格时,绑定到 javascript 函数
  3. 更改值时,将单元格编号作为逗号分隔值写入隐藏列,例如:1、3、5 个单元格编号已更改
  4. 然后,您可以使用隐藏的列值创建一个数组,并准确知道哪些单元格在一行中发生了变化。
于 2011-01-17T22:34:41.570 回答