Hi,
Is there a way to add a second image (aligned right) to an UltraTabControl?
Something like in the attached image.
Thanks!
Hello Ziv,UltraTabControl allows you to add image to any tab via its Appearance. However, by default you can add only one image. If you need to add more images, you can achieve this by some custom Creation Filter. What you need to do in your creation filter is add to TabItemUIElements’ child elements ImageUIElement and set its location. You may use code like this in AfterCreateChildElements method of your creation filter:
// If the parent is TabItemUIElement add one ImageElement to its child collectionif(parent is TabItemUIElement){ // Create the ImageUIElement var imageElement = new ImageUIElement(parent, tabImage); // Set the ImageUIElement Rect relative to its parent Rect imageElement.Rect = new Rectangle(parent.Rect.Right - 19, parent.Rect.Top + 3, 16, 16); // Add the ImageUIElement to its parent child elements collection parent.ChildElements.Add(imageElement);}
Note, this will add the image at the right end of each tab. This way the image may hide part of the tab text. To work around this you can add some additional blank text at the end of each tab like this:tabWithSecondImage.Text += " .";
Attached is small sample demonstrating this approach. Please check my sample and let me know if this is what you are looking for, or if I am missing something.
Hi Milko,
This is exactly what I was after - Thank you!
One small question - Is there any difference if we will use the DrawFilter mechanism to achieve this capability?
Is there any difference in performance between the two?
Thanks again!
Hello Ziv,
I am glad to hear that you were able to solve your issue.
Regarding your question. Using Creation Filter could be just a little faster than using Draw Filter. Looking at our internal logic here is what we are doing. Each control position its UIElement before it is initially shown on the form. This is where we are calling the creation filter methods. So let say this happens once for your tabs (note this will not be true if you have many tabs and scroll them – each time you scroll new tabs are shown and control positions its child UIElements again). After the control size and position all its UIElements it draws itself. The paint of each UIElement happens on phases. This is where draw filter comes into play. Therefore, each time control paints itself some or all of its UIElements may redraw. In some cases UIElements will not reposition and creation filter will not come into play but draw filter will, e.g. if you have hot tracking this will repaint the UIElement of the tab mouse is over but may not reposition the tab. Finally it is depending also on how you are passing the images for your tabs, how you are caching and disposing them.
Please let me know if any additional question arise.