I have a DataGridView bound to a DataTable in a DataSet.
I set all columns of the DataTable to System.Double.
I want the last row of the DataGridView to display "PASS" or "FAIL" depending on some condition of the values in that column.
How do I do this?
Ideas:
lastCell = IIF(condition, Double.PositiveInfinity, Double.NegativeInfinity)
Then, apply some conditional formatting (Inf -> PASS, -Inf -> FAIL) to the final row of the DataGridView.
You could probably create and use a custom
NumberFormatInfo, settingPositiveInfinitySymbolandNegativeInfinitySymbolto the strings you want.But I’d say it would be better to do something like this in the
DataGridView.CellFormattingevent handler – which makes it much clearer what you’re doing and why, and won’t have undesirable side effects e.g. if another cell happens to have an infinite value because of a division by zero.Something like the following air code:
Apologies for the C# code given you’ve tagged the question VB.NET, but you’ll find a VB.NET sample in the MDSN documentation for the CellFormatting event.