Welcome Guest Search | Active Topics | Sign In | Register

How do I set the backround color of a specific cell in a grid VB Options
adcolorlex
Posted: Friday, December 27, 2013 4:10:39 PM
Rank: Newbie
Groups: Member

Joined: 10/6/2011
Posts: 8
I need to set the background color of cells in the VB code behind. What I have below sets the entire column, but I don't see where to do just the 1 cell -

Select Case Trim(SearchText)
Case "Preflight C"
gridrow.Cells(5).Column.CellStyle.BackColor = Color.AliceBlue
Case "Assigned to"
gridrow.Cells(5).Column.CellStyle.BackColor = Color.Aqua
Case "Out for Pro"
gridrow.Cells(5).Column.CellStyle.BackColor = Color.Bisque
Case "Proof Appro"
gridrow.Cells(5).Column.CellStyle.BackColor = Color.Chartreuse
Case "Order to Pr"
gridrow.Cells(5).Column.CellStyle.BackColor = Color.Coral
Case "Line Item t"
gridrow.Cells(5).Column.CellStyle.BackColor = Color.Coral
Case "Material Pr"
gridrow.Cells(5).Column.CellStyle.BackColor = Color.CornflowerBlue
Case "Ink Prep Co"
gridrow.Cells(5).Column.CellStyle.BackColor = Color.DarkGoldenrod
Case "Screen Prep"
gridrow.Cells(5).Column.CellStyle.BackColor = Color.DarkSeaGreen
Case "Printing Co"
gridrow.Cells(5).Column.CellStyle.BackColor = Color.DeepPink
Case "Finishing C"
gridrow.Cells(5).Column.CellStyle.BackColor = Color.Gold
Case "Digital Fin"
gridrow.Cells(5).Column.CellStyle.BackColor = Color.LightBlue
Case "Installatio"
gridrow.Cells(5).Column.CellStyle.BackColor = Color.MediumPurple
Case "Packing Com"
gridrow.Cells(5).Column.CellStyle.BackColor = Color.OliveDrab
Case "Job Shipped", "Job Deliver", "Ready for C", "Put Into In"
gridrow.Cells(5).Column.CellStyle.BackColor = Color.ForestGreen
Case Else
End Select

THANKS,

Wes
eo_support
Posted: Friday, December 27, 2013 5:06:23 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Hi,

You can use StyleField property to do that. See here for an working example:

http://demo.essentialobjects.com/Demos/Grid/Features/Conditional%20Formatting%20-%20Cell%20Based/Demo.aspx

You can take a look of the "Remark" section to see how this feature works.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.