Setting the back brush color of a grid cell to a color picked from a color dialog control


I am trying to set the background color of individual cells in a grid to different colors that have been selected from a color dialog control.

For a test I selected a color from a color dialog control and saved it to an integer variable as follows:

colorArgb  = Me.Label1.ForeColor.ToArgb

The test form contains a grid and I have the following subroutines to format the grid cells:

 AddCellFormattingColumnStyles(Me.grdColorcodes, New FormatCellEventHandler(AddressOf FormatGridCells))
    Private Sub AddCellFormattingColumnStyles(ByVal grid As DataGrid, ByVal handler As FormatCellEventHandler)

        Dim ts As DataGridTableStyle
        ts = New DataGridTableStyle
        Dim dt As DataView
        dt = CType(grid.DataSource, DataView)
        ts.MappingName = "codetable"

    Private Sub FormatGridCells(ByVal sender As Object, ByVal e As DataGridFormatCellEventArgs)
        If e.row = 4 and e.Column = 3 Then
             e.BackBrush = Color.FromArgb(colorArgb)
        End If

The problem is that the statement  'e.BackBrush = Color.FromArgb(colorArgb)' is invalid and I get the error message "Value of "System.Drawing.Color" cannot be converted to 'System.Drawing.Brush'".

Can I some how use the value in the variable 'colorArgb' to set the color of a specific grid cell or is there another way to do so?

Thanks in advance

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

blackbrush = new solidbrush(color.fromargb(colorargb))

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.