Is it possible to embed an image in a formatted tooltip? ie. using an img tag or similar construct?
Under the ToolTip section in the properties window there is a ToolTipTextFormatted property. When you click on the button an editor pops up and you can insert an image from a URL or a file.
Steve,
Ah... so it is possible.... it looks like the resulting text (from the window pictured in your post) is something like this:
<img style="width:##px; height:##px" data="encoded string of the image" />
Since I am looking to set this tooltip programmatically, all I have left to do is to figure out how to encode the image as a string.
Thanks Steve for finding that!
Hello,
You can access the static method for EncodeImage for FromattedLinkLabel as below
Infragistics.Win.
FormattedLinkLabel.FormattedLinkEditor.EncodeImage();
You will also find the DecodeImage() method at the same location
Hi Tim,
You are right. I don't understand why this method was made an instance method and is not static. There should be a static method for this. I've forwarded this over to Infragistics Developer Support so they can get it resolved and we can add a static method.
This is what I ended up doing for one reason or another. I don't remember why I did not try the EncodeImage method.
string imageAsText = null;
BinaryFormatter formatter = new BinaryFormatter();using (MemoryStream ms = new MemoryStream()){ formatter.Serialize(ms, bmp); ms.Position = 0; byte[] bytes = ms.GetBuffer(); imageAsText = Convert.ToBase64String(bytes);}
I can't find this on the FormattedLinkLabel, there is no EditInfo property (presumably because it isn't editable...)
FormattedTextEditInfo.EncodeImage is public but not static, however the FormattedTextEditInfo ctor is internal so I can't instantiate it.
This fn just calls FormattedLinkLabel.Parser.EncodeImage but both Parser and EncodeImage are internal (but static, so why isn't FormattedTextEditInfo.EncodeImage static... this would solve the problem)
In turn this just calls AppStyling.StyleUtilities.ValueToXmlString which is static internal.
So I can see no alternative to having to Instantiate a FormattedTextEditor to encode an image for use in a FormattedLinkLabel... doh
--
Also it doesn't help that the data attribute of img is not described in the help in any detail, neither is an example given in the help, nor are images demonstrated in the FormattedLinkLabel Sample application.
cheers
Martin
Sweet!! This is just what I needed. Thanks Mike!