Hi,
I have a requirement where if the cell content is "Y" i should display "Yes" and if it is "N" it should display "No". for this i am using. For this i am writing a EqualToConditionalFormatRule. my code is as follows
EqualToConditionalFormatRule MyRule = new EqualToConditionalFormatRule();
MyRule.Value = strColVal; //this is "Y"
MyRule.StyleScope = StyleScope.Cell;
Style style = new Style();
style.TargetType = typeof(ConditionalFormattingCellControl);
Setter setter = new Setter();
setter.Property = ConditionalFormattingCellControl.ContentProperty;
setter.Value = item.Value.RuleReplacementString;// this is "Yes"
style.Setters.Add(setter);
MyRule.StyleToApply = style;
dataGrid.Columns.DataColumns[item.Value.ColumnName].ConditionalFormatCollection.Add(MyRule);
But nothing happens.My cell values "Y" is not replaced with "Yes".
I need to do this in code behind since my rules are loaded dynamically.
Can you tell me where i am going wrong.
You would probably be better off using a ValueConverter on the column rather then a ConditionalFormatting rule.
The following post explains how to create a valueConverter.
http://forums.infragistics.com/forums/p/37023/214221.aspx#214221
Hi Darrel as your sugession i ghave created the convertor class and bind it to my column.
But my conditions are loaded dynamicaaly at runtime say i got two conditions loaded for a perticular column where the first condition cnahges the columns cell content from Y to Yes and the other rule states that IF content is N then NO. problem is if one condtion for a column it works fine. How to add more that one convertor conditions to a column.
this is loaded at run time.
<DictReplacementRuleConfig type="map">
<
i id="IsAvailable.ReplacementRule" type=".Sales.Controls.Models.ReplacementRuleConfig">
RuleAppliedOn value="Column"/>
ColumnName value="IsAvailable"/>
RuleName value="IsAvailable.ReplacementRule"/>
RuleExpression value="IsAvailable=Y"/>
RuleReplacementString value="Yes"/>
IsRuleCaseSensitive type="bool" value="false"/>
</
i>
i id="IsAvailable.ReplacementRule1" type=".Sales.Controls.Models.ReplacementRuleConfig">
RuleName value="IsAvailable.ReplacementRule1"/>
RuleExpression value="IsAvailable=N"/>
RuleReplacementString value="No"/>
DictReplacementRuleConfig>
when i iterate this dictonary
Dictionary<string, ReplacementRuleConfig
> dictReplacementRuleConfig = viewmodelobj.dictReplacementRuleConfig;
&& dictReplacementRuleConfig.Count > 0)
{
dictReplacementRuleConfig)
//Infragistics.Controls.Grids.ColumnBase col = dataGrid.Columns[item.Value.ColumnName];
//Binding binding = new Binding(item.Value.ColumnName.ToString()) { Mode = BindingMode.TwoWay, ConverterParameter = item.Value, Converter = (valueConvobj as IValueConverter) };
//(Infragistics.Controls.Grids.Column)dataGrid.Columns[item.Value.ColumnName.ToString()]).DataMemberBinding = binding;
((Infragistics.Controls.Grids.
;
)dataGrid.Columns[item.Value.ColumnName.ToString()]).ValueConverterParameter = item.Value;
}
IValueConverter
culture)
});
strColName = strarr[0];
strColVal = strarr[1];
.IsNullOrEmpty(str))
.Empty;
try
(str == strColVal)
obj.RuleReplacementString;
catch
str;