Wrox Programmer Forums
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases 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 September 12th, 2006, 03:14 PM
Authorized User
 
Join Date: Oct 2005
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need Help with datagridview

Hey whats up guys its been a very long time I havent come by here.
Well I've been having quiet a bit of trouble trying to get individual cells to be a specific color.

What I'm trying to do is that is a specific value within the grid then the color of that specific cell should change to what ever (green,blue, etc)

What I have so far is that I have a datagridview pulling its info from an Access file and then populating it on the grid...within between the pulling of information Im also using an oledbdatareader to try to identify the specific value and if so change the cell color to what ever I need it to be changed...

But so far I ve been having a hard time to achieving this.

Is there a way to do this..or perhaps a better way of doing this than that of what I'm trying to do.

Thankyou in advance guys :D

 
Old September 19th, 2006, 09:36 AM
Authorized User
 
Join Date: Oct 2005
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

**Update**

I was going to say if this seem impossible then...is there a way to do the same, but instead of having a particular cell change color..perhaps just the row it is in?

Also I was wondering how to have error provider indicate which row has an error.

Would I need to use a datareader to read through each one and then stamp it with the provider..or can this be done in another way?



 
Old September 19th, 2006, 10:49 AM
Authorized User
 
Join Date: Oct 2005
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

**** UPDATE Again LOL***

well I found the solution to my problem and I can here to share with all.Tell me what you think and if it worked for you guys

Anyhow if you have a datagridview programmatically taking instruction from your dataadapter then you can go to the _CellFormatting of the datagridview and define the specific column and tell it to put a specific color in the background depending on the value.

Here is the code for you guys who may need help in the future with this stuff

Private Sub grdResults_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEve ntArgs) Handles grdResults.CellFormatting
        If grdResults.Columns(e.ColumnIndex).Name = "AvailabilityStatus" Then
            'Check if this is the reight value
            If e.Value = "A" Then
                e.CellStyle.ForeColor = Color.Green
                e.CellStyle.BackColor = Color.Aqua

            End If
        End If
    End Sub

///

Note to self that the column name is my column...so dont get confused out there lol.

as you can see its simple to do.

Please let me know if it works well for you guys out there.
Take care :D







Similar Threads
Thread Thread Starter Forum Replies Last Post
datagridview help manius VB Databases Basics 1 January 27th, 2008 02:44 AM
DatagridView in C# velan C# 2005 0 June 8th, 2007 09:25 PM
datagridview thirumalai ASP.NET 1.0 and 1.1 Professional 1 April 7th, 2007 03:35 AM
DataGridView akumarp2p C# 2005 1 December 30th, 2006 12:40 PM
datagridview ScottSheck Visual Basic 2005 Basics 0 June 14th, 2006 11:07 AM





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