Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
865
Condition formatting on Bound columns
posted

Here is my situation:

public class MyClass {

 [DisplayName("My Column")]

public decimal MyField { get; set; }

}

A collection (that implements IBindingList) of these classes are bound to a Grid. The grid has a manually created schema that defines MyField, and defines a condition format that should set the foreground red when the value is negative.

The problem is that the data type of the column in the designer defaults to String, and doesn't let me change it because it's a bound column. Subsequently it looks like the conditional formatting is trying to do a less than operation using strings, therefore comparing "-10" to "0", instead of -10 to 0.

The result of this is that the conditional formatting is never applied to negative values.  If I change the conditional format to "Starts With", "-", which works, but this won't help me when I want to do things like comparing whether a decimal value is less than 5 (or any other arbitrary decimal value).

What am I doing wrong here? How can I do "real" conditional formatting based on the underlying data type of the property on the class, rather than the String data type that the manually created schema assumes?

Regards,

Mark