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

Manually hiding a ScreenTip

3 Answers 93 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ofer
Top achievements
Rank 1
Ofer asked on 04 Apr 2016, 01:55 PM

Hi

I'm using a RadOffice2007ScreenTipElement with a RadTreeView, showing it using ScreenTipNeeded and everything is working as expected.

I do have a slight issue - if i start to Drag&Drop, the screen tip will remain visible the whole time (and block my view of other tree elements). I haven't been able to make it disappear. Is there a way to manually remove a screentip while the TreeView is still pressed/active (due to dragging)? 

3 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 06 Apr 2016, 06:56 AM
Hello Ofer,

Thank you for writing.

When you start a drag operation in RadTreeView, note that the selected node is currently noticed as . That is why the screen tip is closed on MouseUp. You can find below a sample code snippet demonstrating how to hide the screen tip by handling the TreeViewElement.DragDropService.PreviewDragOver event:
public Form1()
{
    InitializeComponent();
 
    this.radTreeView1.AllowDragDrop = true;
    this.radTreeView1.ScreenTipNeeded += radTreeView1_ScreenTipNeeded;
    this.radTreeView1.TreeViewElement.DragDropService.PreviewDragOver += DragDropService_PreviewDragOver; 
}
 
private void DragDropService_PreviewDragOver(object sender, RadDragOverEventArgs e)
{
    ((ComponentBehavior)this.radTreeView1.Behavior).GetType().GetProperties(BindingFlags.NonPublic | BindingFlags.Instance);
    PropertyInfo barProperty = ((ComponentBehavior)this.radTreeView1.Behavior).GetType().GetProperty("ScreenPresenter",
                                                                                             BindingFlags.NonPublic | BindingFlags.Instance);
    Form screenTip = barProperty.GetValue(((ComponentBehavior)this.radTreeView1.Behavior), null) as Form;
    screenTip.Hide();            
}
 
RadOffice2007ScreenTipElement screenTip = new RadOffice2007ScreenTipElement();
Size size = new Size(120, 70);
Padding pad = new Padding(2);
 
private void radTreeView1_ScreenTipNeeded(object sender, Telerik.WinControls.ScreenTipNeededEventArgs e)
{
    TreeNodeElement node = e.Item as TreeNodeElement;
    if (node != null)
    {
        screenTip.MainTextLabel.Image = node.ImageElement.Image;
        screenTip.MainTextLabel.TextImageRelation = TextImageRelation.ImageBeforeText;
        screenTip.MainTextLabel.Padding = pad;
        screenTip.MainTextLabel.Text = "This is " + node.ContentElement.Text;
        screenTip.MainTextLabel.Margin = new System.Windows.Forms.Padding(10);
        screenTip.CaptionLabel.Padding = pad;
        screenTip.CaptionLabel.Text = node.ContentElement.Text;
        screenTip.EnableCustomSize = true;
        screenTip.AutoSize = false;
        screenTip.Size = size;
        node.ScreenTip = this.screenTip;
    }
}

I hope this information helps. Should you have further questions I would be glad to help.

 Regards,
Dess
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Ofer
Top achievements
Rank 1
answered on 06 Apr 2016, 08:07 AM

Quite a hack, but it works :)

Using reflection to get properties is a bit problematic (Telerik has a history of renaming/deprecating) so it will be nice it there will be an easier way to do so in the future - just add a "Hide()" method to RadOffice2007ScreenTipElement.

Thanks 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 06 Apr 2016, 08:28 AM
Hello Ofer,

Thank you for writing back.

I have logged it in our feedback portal. You can track its progress, subscribe for status changes and add your vote/comment to it on the following link - feedback item.

I have also updated your Telerik points.

If you have any additional questions, please let me know.
Regards,
Dess
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
General Discussions
Asked by
Ofer
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Ofer
Top achievements
Rank 1
Share this question
or