Color DataGridView cell on exception
I'm using VB.NET 2005, and would like to color a cell on a DataGridView if an exception has been invoked. I have the following code snippet:
Is there a clever bit of code I need to use that will allow me to color this particular cell?
' ############ GET THE NEW 'FROM' DATE ############
tblRow.Item("From") = Convert.ToDateTime(strNewFromDate)
Catch ex As Exception
' Problem with this date field, so leave blank
' Add 1 to the number of warnings count
intNumberOfWarnings += 1
' Colour the cell in error
Coloring a Cell
This is just a starting point for you. You'll have to tweak it a bit to make it work for you.
dgv.CurrentRow.DefaultCellStyle.BackColor = Color.BlanchedAlmond
this will at least highlight the entire row. Play around with currentrow.currentcell, might be what your looking for. Hope this helps.
Thanks for the tip.
I've collected the rows and cells "in error" in an array, and I've looped through the array with the following line:
Me.DataGridView1.Rows(arWarningRow(intArrayPosition)).Cells(arWarningCell(intArrayPosition)).style.BackColor = Color.Yellow
By freesoft_2000 in forum Java
Last Post: 11-25-2006, 04:53 AM
By FFW in forum VB Classic
Last Post: 09-27-2005, 09:48 PM
By David Williams in forum .NET
Last Post: 05-28-2002, 02:19 PM
By Mark Taylor in forum Architecture and Design
Last Post: 10-25-2000, 07:21 PM
By Mark Taylor in forum Web
Last Post: 10-24-2000, 10:08 AM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center