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

Interactive form on tab hover

1 Answer 151 Views
PageView
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 17 Aug 2020, 11:59 AM

Hi,

We need to generate a form when you hover over certain tabs on our PageView, as it needs to be interactive, I'm using a ShapedForm to appear on mouse hover over each tab.If there's a better way to do this, let me know.  

The issue is the position it appears in, I can get it to appear where my cursor is easy enough, but I would like it to appear directly next to the tab, the tabs are horizontal on the left hand side, so would like it to appear to the right of the tabs with the top of the tab matching the top of my generated form. 

I'm iterating through each RadPageViewStripElement and subscribing to the mouse hover event, so in my event I have RadPageViewStripItem, but I am not sure how I get the exact position of that tab using that object, as the locations are always relative to the control it is in. 

Any help would be appreciated.

Thanks,

Dan

1 Answer, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 19 Aug 2020, 03:42 PM

Hello, Daniel,

Thank you for the provided description. Following it I created a sample project in order to test the scenario that you have.

In order to set a custom location where the form should appear it is necessary to calculate the exact location. Note that there are several methods that might be quite useful for this: PointFromScreenPointToScreen, PointFromControl, and PointToControl. In my sample, I use the PointToScreen method to calculate the point and a little offset. Please refer to the following code snippet:

public RadForm1()
{
    InitializeComponent();
    var stripElement = radPageView1.ViewElement as RadPageViewStripElement;

    foreach (RadPageViewItem page in stripElement.Items)
    {
        page.MouseHover += this.Page_MouseHover;
    }
}

private void Page_MouseHover(object sender, EventArgs e)
{
    var item = (RadPageViewItem)sender;
    var pt = this.radPageView1.PointToScreen(item.ControlBoundingRectangle.Location);
    pt.Offset(item.ControlBoundingRectangle.Width, 0);
     ShapedForm f = new ShapedForm();
    f.Show();
    f.Location = pt;
}

Note, that this is a sample demonstration. Feel free to modify it in a way that suits your requirement.

I hope this helps. Let me know if I can assist you further.

Regards,
Nadya
Progress Telerik

Tags
PageView
Asked by
Daniel
Top achievements
Rank 1
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or