Wrox Programmer Forums
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 22nd, 2006, 08:26 AM
Registered User
Join Date: Jun 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default change cell color

Hi, I bound DataSet to DataGridview to display data from SQL DB, I want to change row color to blue, red or write based on row data retrived if the row data meet some condition, any clue?


Old July 13th, 2006, 04:39 AM
Registered User
Join Date: Jul 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

This is code to solve your problem

Private Sub dgGrid_RowPrePaint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewRowPrePaintEventA rgs) Handles dgGrid.RowPrePaint
        Dim tmpCell As New DataGridViewCellStyle()
        tmpCell.BackColor = Color.Beige
            If GetProperGridCellValue(dgGrid.Item("qty", e.RowIndex), 0) = 1 Then dgGrid.Rows(e.RowIndex).DefaultCellStyle = tmpCell

        End Try
    End Sub

Old October 4th, 2006, 08:55 AM
Registered User
Join Date: Oct 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Mracket

Maybe a stupid question, but vs say that GetProperGridCellValue is not declared when it read that code. What is it meant to be dim as ?

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get Excel Cell color populate .NET Framework 2.0 2 March 3rd, 2014 04:25 AM
Change border color for every cell of a table jdang67 CSS Cascading Style Sheets 10 May 6th, 2010 12:21 AM
Change the backround color to cell ricespn Beginning VB 6 0 November 4th, 2006 12:39 PM
Change Cell Color phungleon HTML Code Clinic 2 April 9th, 2006 12:36 AM
change background color of cell based on value vurtman ASP.NET 1.0 and 1.1 Basics 4 February 26th, 2004 03:52 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.