Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2006-04-07
1
Medium Priority
?
303 Views
Last Modified: 2012-05-05
Hi!

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



0
Comment
Question by:laschwabe
1 Comment
 
LVL 4

Accepted Solution

by:
broadbent earned 2000 total points
ID: 16399343
try
blackbrush = new solidbrush(color.fromargb(colorargb))
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question