I have a requirement to use different font color in the same text of label. (Example: The label text is "Name*" in which asterix should be marked RED.)
This is not possible using UltraLabel, so I am using UltraFormattedLinkLabel. But the problem with UltraFormattedLinkLabel is that it does not allow to add hotkey, which is possible through UltraLabel by adding ampersand as desired. (Example: "&Name*" for N to be the hotkey).
How do I achieve hotkey functionality as well as two font color in single label? Using two UltraLabels does not work, because the two label texts looks separated, with space between them.
Hello Sudesh,
Yes, you are correct; UltraFormattedLinkLabel does not allow adding of hotkey. However, why you need this key for a label? If what you need is to underline a letter in the label, you may use <u> tag in UltraFormattedLinkLabel. If this is not your case can you let me know why you need hotkey for a label?
Looking forward to your reply.
I need hotkey for the label to get focus on the textbox associated with label on pressing the hotkey.
Example: For label with text as Name*, I want to set 'N' as hotkey so that when I press Alt+n, the focus is set on the textbox next to the label.
Then you will need to use UltraLabel, as UltraFormattedLinkLabel does not support hotkey. What you can do to color the star char is implement your own DrawFilter for all the labels in your application. In your draw filter you will need to paint the entire text of the label by yourself with the colors you need. Attached is a small sample project showing how to achieve this. Please check my sample and let me know if this is what you are looking for or if I am missing something.
Thanks Milko for the Drawfilter suggestion and the sample project. This works fine but there is one problem. The hotkey (underscore) is seen every time, which should ideally appear only after 'Alt' key is pressed for the first time.
Hi Sudesh,
In order to capture the ALT key globally to the application you have to use IMessageFilter and according to the state of the ALT key you can draw underline or not. Check out the attached sample application that I modified according to your latest requirement.