Back Color Gridview rowstyle event does not work in devexpress

1.2k views Asked by At

I have code like this:

Private Sub GV_Data_Kerja_RowStyle(sender As System.Object, e As DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs) Handles GV_Data_Kerja.RowStyle
    If row_mod = 1 Then
        Dim c As New Color
        c = Color.Yellow
        If e.Appearance.BackColor = c Then
            e.Appearance.BackColor = Nothing
            MessageBox.Show(e.Appearance.BackColor.ToString)
        Else
            e.Appearance.BackColor = c
            MessageBox.Show(e.Appearance.BackColor.ToString)
        End If
        MessageBox.Show(e.Appearance.BackColor.ToString)
        row_mod = 0
    End If
End Sub

It triggered by Sub GV_Data_Kerja.RefreshRow(RowHandled), but it does not work. In every message box which placed there, it always return white color. This mean, my code for change back color does not work. Can anyone help me?

3

There are 3 answers

0
IvanP On BEST ANSWER

Looks to me that your code kinda works. I have tried it and it changes color. But it works when I remove MessageBox debug messages.

Advice DO NOT use MessageBox to display data as it interferes with what you are trying to debug, instead write to log file or console output.

It looks like you put them to debug, they caused all sorts of problems, you solved original problem but MessageBox problems remained.

1
Adam On

THIS may be what you are looking for from MSDN. Change e.Appearance.BorderColor to

e.Appearance.BackColor.......
0
Shanmuga Priyan On

Try this Code:(Using GridView CustomDrawCell Events)

  Dim state As GridRowCellState
        state = DirectCast(e.Cell, GridCellInfo).State
        If (state And GridRowCellState.Selected) = GridRowCellState.Selected Then
            e.Appearance.BackColor = c
        End If