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,
I'm a little puzzled by what you are doing here. Setting properties on the cell inside a DrawFilter is probably not a good idea. It's certainly not very efficient. It seems like you should be setting properties like Activation, Style, and Value of the cell inside the InitializeLayout or InitializeRow events.
But this code will not work correctly in any case, for a couple of reason. First, you are trying to set the Value of an integer cell to a string and that won't work. Second, because you are losing the original value of the cell. If this code fires twice you will end up added addition bold tags to it every time, and you will never clear these tags.
What I would do is hide your integer column with the "real" value in it and then display an unbound string column to the user. I would use the InitializeRow event to get the value of the real column, convert it into a string, modify it however you like, and the set the Value on the unbound column.
Hello Mike,
Thanks for the reply...Its my mistake i did not remove the lines like Activation and style for the code, i agree it has to be in InitializeRow...
Many of the article says we can achieve highlighting the Text using simple FormattedText., so i was experimenting using FormattedText,
For instance i have a ID columns with values
ID
123
1235
1234556
say i want to format the text in the column to change the appearance of the digit 55 to bold using Formatted Text..
if you can please provide the sample for highlighting the text for the integer column it would be really helpful..
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,
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..
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.
Tried with the above code..It works fine... :)
Thanks a ton.... :)
The above code seems like not working..Please find the example below & the snapshot for your reference.
1. The original Text before highlighting the character 'P' in the text
Original Text : SYBIL H. POLLET & MICHAEL N. POLLET, TIC
2. After escaping the Original Text using below code, the & is replaced with &as shown below
Infragistics.Win.FormattedLinkLabel.ParsedFormattedTextValue.EscapeXML(OriginalText)
Escaped XML: SYBIL H. POLLET & MICHAEL N. POLLET, TIC
3. At the time of formatting the escaped text, the formatting is also applied for the character 'P' in & as shown below, which supposed to be incorrect
Formatted Text: SYBIL H. <b>P</b>OLLET &am<b>P</b>; MICHAEL N. <b>P</b>OLLET, TIC
4. Please find the result that is shown in the grid after formatting the cell text.
Please help me with this..
Hi,
As far as I know, there's no superscript or subscript functionality in the FormattedText support. I assume <sup> is an html tag? We don't actually use html, although our custom format is similar. So that tag probably isn't supported if it's not working.
Hi,Is there any way to add a superscript in Ultragrid cell. My need is to add a alphabet superscript in ultragrid cell. I have tried the <sup>text</sup> tag as we have used <b>text</b> tag in above example.
<b></b> tag is working fine. But <sup></sup> tag is not working. Is there any other tags present to achieve this. Please help.
eg. Sample TextM
Thanks in advance.
I don't see any easy way to handle so complex a case. You probably have to string out the escape codes first, then applying your formatting, and then put them back in. Or write your own Replace method that skips over the appropriate codes.
Here's a list of codes that are escaped by the EscapeXML method.
& = &
< = <
> = >
" = "