In Excel, there is an option to format and display negative numbers in parentheses and red (with no negative sign showing) . Is is possible to format negative numbers in the grid the same way?
I can change the color to red in the InitializeRow even by testing the values and changing the cell appearance. If I change the number to a string, I can have the parentheses, but then I have to strip out the parens and convert when trying to get the value.
Consolidate information with the Ampersand image (and) · Select the cell where you need to put the joined information. · Type = and select the principal cell you need to join. This is how 0 in front of numbers comes along side.
If you are going to be writing code to do this at run-time, anyway, it would be a lot easier and a lot less code to just use the InitializeRow event. :)
That did the trick. Thanks for your help.
Class Level Variables:
Dim condition1 As New OperatorCondition(ConditionOperator.LessThan, 0)Dim appearance1 as Infragistics.Win.Appearance = New Infragistics.Win.Appearance()Dim valAppearance1 As New ConditionValueAppearance()
From Form_Load:
appearance1.ForeColor = Color.RedvalAppearance1.Add(condition1, appearance1)
Then in your InitializeLayout:
For ii As Integer = 1 To .Columns.Count - 1 Dim col As UltraGridColumn = .Columns(ii) col.ValueBasedAppearance = valAppearance1 col.Format = "###0.0000;(###0.0000);0.0000"Next ii
Awesome video. Thanks for the extra effort!!! It was very helpful.
One question. In my case I do not define my columns up front. They are defined when I bind my DataTable since I don't know what columns I will have up front. Using your example, I created a column in the designer and then followed your steps to create the ConditionValueAppearance.
In my code, I create a class level variable to hold the ConditionValueAppearance. I I then copied the code that was created in the .Designer file into the Form_Load and assign it to my modular level variable. In Initialize_Layout, I set the ValueBasedAppearance and the format. The formatting works, but the ValueBasedAppearance does not seemed to.
Appearance1.ForeColor = Color.Red
_negValueBasedAppearance = New Infragistics.Win.ConditionValueAppearance(New Infragistics.Win.ICondition() {CType(New Infragistics.Win.OperatorCondition(Infragistics.Win.ConditionOperator.LessThan, "0", True, GetType(String)), Infragistics.Win.ICondition)}, New Infragistics.Win.Appearance() {Appearance1})
From InializeLayout
col.ValueBasedAppearance = _negValueBasedAppearance
col.Format = "###0.0000;(###0.0000);0.0000"
Next ii