Manually hiding a ScreenTip

4 posts, 1 answers
  1. Ofer
    Ofer avatar
    2 posts
    Member since:
    Feb 2013

    Posted 04 Apr Link to this post

    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)? 

  2. Answer
    Dess
    Admin
    Dess avatar
    1609 posts

    Posted 06 Apr Link to this post

    Hello Ofer,

    Thank you for writing.

    When you start a drag operation in RadTreeView, note that the selected node is currently noticed as hovered. 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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Ofer
    Ofer avatar
    2 posts
    Member since:
    Feb 2013

    Posted 06 Apr in reply to Dess Link to this post

    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 

  5. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 06 Apr Link to this post

    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.
Back to Top