Hi
I've got a Grid which has a single column in a row of two columns. This column is using the DropDown control as a lookup via the ValueList property on the Column. It works great.
However, two questions:
1. Using conditional formatting, is it possible to apply a format derived from one column across a whole row (or to another column) e.g. If ColumnA = 1 then set ColumnB's ForeColor to Red?
2. I can't get Conditional Formatting working using the DropDown column. It seems that the formats themselves come from the "real" column settings - but the logic to determine a match (with Operators) works against the lookup value e.g. I have a column called StatusId, where this can be 0, 1, or 2. The DropDown resolves this to "Live", "Cancelled", or "Complete". I want to color-code the rows depending on this status value. Where do I put the conditional format - on the WinGrid column (in which case what should I set the operators to match against?) or against the DropDown control? I have tried both approaches but neither seems to "work". Any advice greatly appreciated.
Thanks
Isaac
Issac,
If I read your first question correctly, you want to resolve a cell's appearance based on the value in a different column. This is possible using a FormulaCondition, which is only available if you site an UltraCalcManager on the form. An example of a formula that you could use is "[Column 1] = 1"
As for your second issue, the values that a condition will compare against 'owner' values; that is to say, whatever is actually stored in a cell is what's used for comparison. When you have text showing that maps to a number, that does not necessarily have anything to do with the value, since it could have been altered with a DataFilter, editor, etc. You could submit a feature request to expose the option on whether the grid should provide a condition/ValueBasedAppearance with the display text instead of the value, but for now you will have to use the underlying value.
-Matt
Matt,
Another question. I am now using the FormulaCondition with the UltraCalcManager. If I had ten columns and wanted them all to show as Red based on the value of an eleventh column, do I have to make separate Formulas for each column, each with identical conditions e.g. If [Column 11] = 0 then [Set forecolour = Red]?
Thanks again
Seems like I mis-remembered where the Condition will get its value; in the case of a ValueList, it will indeed get what is shown, so you would use "Passed", "Pending" or "Failed" for your comparisons. As to why they aren't showing, does it only happen when the cell is the active cell of the grid? If so, it's possible that the ActiveCellAppearance or ActiveRowAppearance are overriding the appearance that the condition is providing.
As for your second question regarding formula conditions, yes, you would need to have a new ForumlaCondition for each column, though you could re-use the appearance object if you are doing this in code.
This brings up an interesting point, which I didn't notice before because I defined my schema at design-time but didn't have it bound to a source (so my column at the time was a string). What I would consider a bug is that if you have a ValueList at design-time on that column, it doesn't appear on the condition designer's column as well, which would prevent you from selecting this value. If you would like, you can submit this to Developer Support:
Get Help
As far as the best workarounds:
1) Use a FormulaCondition instead of an OperatorCondition, which will allow you to type in strings (i.e. '[//FormulaCondition/ConditionValue] = "Passed" '). This will require the precense of an UltraCalcManager on the form.
2) Use the InitializeRow event of the grid, where you can check the text of the cell in question and set the color accordingly.
With both of these workarounds, keep in mind what I said in an earlier post about the ActiveCellAppearance and ActiveRowAppearance overrinding these settings.
How can I use the value "Passed" for my comparison on the Grid at design time? The underlying column type is Int32 (i.e. the Id) and the Condition designer only wants to accept Int32s for the ValueBasedAppearance operators.
The way I got around this wasto manually change the Appearance of the ValueListItems instead - so I ended up not using the ValueBasedAppearance at all in the end.
Is there a better way out there?