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 に答える