RoundedCorner for RadOffice2007ScreenTipElement

1 Answer 25 Views
General Discussions
Kumaran
Top achievements
Rank 1
Iron
Kumaran asked on 21 Sep 2021, 10:15 AM

Hello,

I am trying to get the screentip with a rounded corner. I have changed the Shape to RoundRectShape. Although, the shape is now rounded rect, but I still see the corner is painted with some other color.

Below is the code of my custom screentipelement

Padding = new Padding(4, 0, 4, 0);
ForeColor = Color.White;
Shape = new RoundRectShape(4);

ScreenTipFill.GradientStyle = GradientStyles.Solid;
ScreenTipFill.BackColor = Color.Blue;

ScreenTipBorder.BoxStyle = BorderBoxStyle.SingleBorder;
ScreenTipBorder.ForeColor = Color.Blue;

This is my output

Thanks

1 Answer, 1 is accepted

Sort by
0
Todor Vyagov
Telerik team
answered on 22 Sep 2021, 03:02 PM

Hi, Kumaran,

Note that the RadOffice2007ScreenTipElement is added to a Form before it is shown. In order to apply a shape to a form in Windows Forms we need to set the Region property of the Form. And here comes the problem that Regions do not support anti-aliasing. This means that when we apply a rounded rectangle shape to the form its corners will be edgy. Here is a screenshot of a rounded screen-tip:

You can see the corners are not smooth corners.

If you are still interested in this approach here is the code I am using:

public partial class RadForm1 : Telerik.WinControls.UI.RadForm
{
    private RadOffice2007ScreenTipElement screenTip;

    public RadForm1()
    {
        InitializeComponent();

        this.radButton1.ScreenTipNeeded += this.RadButton1_ScreenTipNeeded;

        screenTip = new RadOffice2007ScreenTipElement();
        screenTip.Padding = new Padding(4, 0, 4, 0);
        screenTip.ForeColor = Color.White;

        screenTip.ScreenTipFill.GradientStyle = GradientStyles.Solid;
        screenTip.ScreenTipFill.BackColor = Color.Blue;

        screenTip.ScreenTipBorder.BoxStyle = BorderBoxStyle.SingleBorder;
        screenTip.ScreenTipBorder.ForeColor = Color.Blue;
        screenTip.PropertyChanged += this.ScreenTip_PropertyChanged;
    }

    private void ScreenTip_PropertyChanged(object sender, PropertyChangedEventArgs e)
    {
        if (e.PropertyName == "Parent" && screenTip.Parent != null)
        {
            screenTip.ElementTree.RootElement.Shape = new RoundRectShape(4);
        }
    }

    private void RadButton1_ScreenTipNeeded(object sender, ScreenTipNeededEventArgs e)
    {
        e.Item.ScreenTip = screenTip;
    }
}

I hope this helps.

Regards,
Todor Vyagov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Kumaran
Top achievements
Rank 1
Iron
commented on 22 Sep 2021, 04:56 PM

Hello Todor,

Thanks for your response. I don't think, the above-mentioned approach will work for me.

Thanks

Todor Vyagov
Telerik team
commented on 23 Sep 2021, 10:47 AM

In case you are using the ScreenTipNeeded event and setting the Office2007ScreenTipElement to the event arguments you can subscribe to the PropertyChanged event of the Office2007ScreenTipElement and set the shape of the RootElement as shown in my previous post.

If your approach is different, can you please share a full code snippet that will allow me to provide a more specific solution?

 
Tags
General Discussions
Asked by
Kumaran
Top achievements
Rank 1
Iron
Answers by
Todor Vyagov
Telerik team
Share this question
or