This is a migrated thread and some comments may be shown as answers.

Screentip Size

4 Answers 68 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
Veteran
James asked on 24 Sep 2019, 09:37 PM

I have a question about auto-sized screentips.

I would like to measure the screentip before it is displayed and move its position above a control instead of beneath it. In order to move the screentip above a control, I need to know its height.

My question is how can I get a screentip's height before it is displayed? I assume I need to invoke a method. However, everything method I have tried has not worked.(ie DesiredSize)

Thanks in advance.

4 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 25 Sep 2019, 07:41 AM

Hello, James,   

You can handle the PropertyChanged event of RadOffice2007ScreenTipElement. If the PropertyName is "Bounds", this means that the size is updated according to the content that needs to be displayed. 

        public RadForm1()
        {
            InitializeComponent();

            this.radButton1.Text = "This is a very long text that needs more space to be displayed";
            this.radButton1.ScreenTipNeeded += radButton1_ScreenTipNeeded;
            screenTip.PropertyChanged += screenTip_PropertyChanged;
        }

        private void screenTip_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "Bounds")
            {
                Console.WriteLine(screenTip.Size);
            }
        }
        
        RadOffice2007ScreenTipElement screenTip = new RadOffice2007ScreenTipElement();

        private void radButton1_ScreenTipNeeded(object sender, ScreenTipNeededEventArgs e)
        {
            RadButtonElement element = e.Item as RadButtonElement;
            if (e.Item != null)
            {
                screenTip.CaptionLabel.Text = "Select Employee Name";
                screenTip.MainTextLabel.Text = "Current: " + element.Text;
                screenTip.FooterTextLabel.Text = "Thank you!";
                screenTip.FooterVisible = true;
                element.ScreenTip = screenTip;
            }
        }

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
James
Top achievements
Rank 1
Veteran
answered on 25 Sep 2019, 05:57 PM

Thank you Dess.

This helps. However, I still have an issue.

After I get the size of the screentip in the PropertyChanged event, how would I offset the screentip in that method?

Currently, I am offsetting the Screentip in the ScreenTipNeeded event using the e.Offset property (ScreenTipNeededEventArgs).The PropertyChanged event isn't raised until after the screentip is assigned to element.screentip.

I cannot seem to locate a method or property to offset the screentip other than the ScreenTipNeededEventArgs passed into the ScreenTipNeeded event.

0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 27 Sep 2019, 11:44 AM

 

Hello, James,   

Indeed, you will have the real screen tip size too late for setting the ScreenTipNeededEventArgs.Offset in the ScreenTipNeeded event. Note that the screen tip's size is calculated when you are going to show it. But the ScreenTipNeeded event has already been fired providing the necessary information for the screen tip. 
Before setting the offset, you can force measuring the screen tip and thus you will know its size. Please refer to the following code snippet:

        public RadForm1()
        {
            InitializeComponent();

            this.radButton1.Text = "This is a very long text that needs more space to be displayed" + Environment.NewLine + "second " + Environment.NewLine + "third";
            this.radButton1.ScreenTipNeeded += radButton1_ScreenTipNeeded;
        }

        RadOffice2007ScreenTipElement screenTip = new RadOffice2007ScreenTipElement();

        private void radButton1_ScreenTipNeeded(object sender, ScreenTipNeededEventArgs e)
        {
            RadButtonElement element = e.Item as RadButtonElement;
            if (e.Item != null)
            {
                screenTip.MainTextLabel.Font = new System.Drawing.Font("Arial", 16f, FontStyle.Bold);
                screenTip.CaptionLabel.Text = "Select Employee Name";
                screenTip.MainTextLabel.Text = "Current: " + element.Text;
                screenTip.FooterTextLabel.Text = "Thank you!";
                screenTip.FooterVisible = true;
                element.ScreenTip = screenTip;

                SizeF f = MeasurementControl.ThreadInstance.GetDesiredSize(screenTip, new SizeF(1000, 1000));
                e.Offset = new System.Drawing.Size(0, (int)-f.Height);
            }
        }

Should you have further questions please let me know.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
James
Top achievements
Rank 1
Veteran
answered on 09 Oct 2019, 07:45 PM

Thank you Dess!

 

Your last reply was exactly what I was looking for and it works.

 

Tags
General Discussions
Asked by
James
Top achievements
Rank 1
Veteran
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
James
Top achievements
Rank 1
Veteran
Share this question
or