Hi
Please find below the code which i am using to highlight the part of the text in the UltraGridCell at runtime based on the text entered in the TextEditor, below code works fine for strings, but when i type in integer 1 in the texteditor i am getting an error "Cannot convert string to Integer"
As far as my knowledge goes in the below code since i am using Replace() with the html code in it, i assume this is not able to convert to integer which is why i get the error..
public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams){ UltraGridCell aCell; Font font = this.ultraGrid1.Font; switch (drawPhase) { case DrawPhase.AfterDrawForeground:
Please help me to overcome this problem..
Thanks
Manoj
Hi Manoj,
Yeah, there's a static method you can use to apply the proper escape sequences to the text before you do the Replace.
Infragistics.Win.FormattedLinkLabel.ParsedFormattedTextValue.EscapeXML
I think if you call that method on the string before you do the Replace call, it should work.
Hi Mike,
As far as my observation goes..I checked the data of the few cells and i see this happens for the cells that contain the special characters say like "&, @"..etc..;
Is there any way to find and escape these characters while formatting the cell value, please let me know..
Does this always happen for the same cells? There must be something off about the Value in that particular cell that is causing the formatting not to take. For example, maybe the cell value contains a "/" character and it's getting interpreted as an escape code so that the "less than" bracket show up as a literal instead of being a tag.
Hi Mike
I am using the below code to highlight part of the text
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { // Hide the "real" data column e.Layout.Bands[0].Columns["Int32 1"].Hidden = true; // Add an unbound column UltraGridColumn formattedColumn = e.Layout.Bands[0].Columns.Add("Formatted Int32 1"); formattedColumn.DataType = typeof(string); formattedColumn.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.FormattedText; formattedColumn.Header.Caption = "Int32 1"; } private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e) { // Make sure the unbound column exists. if (e.Row.Band.Columns.Exists("Formatted Int32 1")) { // Get hte int value from the Int32 1 column. int realValue = (int)e.Row.Cells["Int32 1"].Value; // Build a formatted string for the text and apply it to the unbound column. string formattedText = realValue.ToString().Replace("55", "<b>55</b>"); e.Row.Cells["Formatted Int32 1"].Value = formattedText;
}
This works fine, But some time i dont see the formatted text with bold characters, instead i see the
text itself pasted as "<b>BRA</b>", pleae find the snap shot below for your reference,
observe the text highlighted in red Circle, Please help me with this..
Thanks..
Yeah correct, things like sort, filter might not behave correctly on the numbers columns which
is treated as strings...
Regards