4

私の xtraGrid には、カスタム スタイルのイベント リスナーがあります。

  FooGridView.RowCellStyle += new DevExpress.XtraGrid.Views.Grid.RowCellStyleEventHandler(FooGridView_RowCellStyle);


  private void FooGridView_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
        {

            DevExpress.XtraGrid.Views.Grid.GridView vw = (sender as DevExpress.XtraGrid.Views.Grid.GridView);
            try
            {
                DataRow DR = vw.GetDataRow(vw.GetRowHandle(e.RowHandle));

                if (**some condition based on one or more values in the DataRow**)
                {
                    e.Appearance.Font = new System.Drawing.Font(e.Appearance.Font, System.Drawing.FontStyle.Strikeout);
                    e.Appearance.ForeColor = Color.LightGray;
                }
                else
                {
                    e.Appearance.Font = new System.Drawing.Font(e.Appearance.Font, System.Drawing.FontStyle.Regular);
                    e.Appearance.ForeColor = Color.Black;
                }

            }
            catch (Exception ex) { }
        }

グリッドの列ヘッダーをクリックしてグリッドを並べ替えた後、並べ替えによって行が並べ替えられた後、間違った行に書式設定が適用されてしまいます。その問題にどう対処するか?

4

1 に答える 1

5

あなたはあなたにe.RowHandle与えられた を取り、それを に変換していDataSourceHandleます。次に、 で呼び出しGetDataRowていDataSourceHandleます。

ただし、GetDataRowデータ ソース ハンドルではなく、行ハンドルを受け取ります。これを試して:

DataRow DR = vw.GetDataRow(e.RowHandle);
于 2011-08-12T17:22:22.097 に答える