|
-
Mar 31st, 2005, 02:47 PM
#1
Thread Starter
Frenzied Member
datagrid row
I need to change the color of a row when my form loads. I'm using the following code, but it changes the color of all the rows...any suggestions?
VB Code:
Dim i As Integer
With ds.Tables("checks")
For i = 0 To .Rows.Count - 1
If .Rows(i)("check_no") = "2" Then
dgView.BackColor = Color.Red
End If
Next
End With
It's tough being an unhandled exception...
___________
VB.NET 2008
VB.NET 2010
ORACLE 11g
CRYSTAL 11
-
Apr 1st, 2005, 08:24 AM
#2
Thread Starter
Frenzied Member
Re: datagrid row
help
It's tough being an unhandled exception...
___________
VB.NET 2008
VB.NET 2010
ORACLE 11g
CRYSTAL 11
-
Apr 1st, 2005, 08:29 AM
#3
Lively Member
Re: datagrid row
simple man u just avoid use the for loop
like
With ds.Tables("checks")
If .Rows(i)("check_no") = "2" Then
.row=2
dgView.BackColor = Color.Red
End If
End With
bye
-
Apr 1st, 2005, 08:33 AM
#4
Hyperactive Member
Re: datagrid row
As I said in my response to one of your other posts about this subject, you need to work on your own custom data grid column to allow rows to have different back colours.
In a nutshell, you override the Paint event for the cell as it is painted. If you really really can't work the code out from the other sample then PM me and I'll work something out for you later this evening.
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind.
Dr. Seuss 
-
Apr 4th, 2005, 09:01 AM
#5
Frenzied Member
Re: datagrid row
Lil Ms Squirrel, i have done that several times but i could only change the forecolor and backcolor of a total column. i have never got to control a single cell property. why?? because ,
when you override the paint method it is easy to color a column according to it's index ( ordinal no. ) but with specific cells it is very hard as i don't know how much rows are there in the grid nor do i know if the user have arranged them by clicking any column headers. moreover if i have several cells to be painted in different locations. how can i select them without changing the color of the other cells in the grid
that is the question
Thx in advance
RGDS
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|