Windows Develop Bookmark and Share   
 index > Windows Forms General > DataGridViewCell - ForeColor based on cell value
 

DataGridViewCell - ForeColor based on cell value

Hi,

I have an unbound DataGridView and I need cells that contain double values to change their ForeColor based on a specific value in the cell.
So, naturally, I'm inheriting my own cell from DataGridViewCell, add a couple properties and override GetFormattedValue. So, whenever GetFormattedValue is called, I check the value and give appropriate ForeColor. This works fine, except when I want to use a custom DefaultCellStyle.Format for my own DataGridViewColumns. This format is lost when I override GetFormattedValue, because for some reason, GetFormattedValue only works when I return a string?? (Why is that? When I just return the double object, my cells are empty).

Thanks,

Tom
Daikoku  Tuesday, September 27, 2005 10:02 AM
ok, I got around this by just doing something like return ((double)value).ToString(cellStyle.Format);
However, still I'm wondering why my cells are empty when I return a double and not a string?
Daikoku  Tuesday, September 27, 2005 10:12 AM

You can use google to search for other answers

Custom Search

More Threads

• How to remove rows in a datagridview?
• Max # of File System Watcher's
• Issue with Dataset while reading from XML
• Samba Struggles
• c# 2.0 dataGridView
• Updating UI flickers??
• handling exceptions
• add new form or winwdow?
• Crashing when adding a Data Source
• Scrollbar and dynamic content