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

Strange ExplorerBar behaviour

2 Answers 101 Views
PageView
This is a migrated thread and some comments may be shown as answers.
Ian
Top achievements
Rank 1
Ian asked on 18 Dec 2011, 08:02 AM
Hi Telerik

I've been struggling over the weekend with a problem in our app. We currently use a pageview in stack mode to display a collection of items grouped into the pageview's pages. The pageview and its pages are generated programmatically and we use another control dock/filled into the pages to contain the items.

The items display fine in stack mode but the number of items to be displayed now requires a mechanism of display which allows scrolling. I thought I woud use explorerbar for this but when I change the mode of the pageview to explorerbar the controls containing the items no longer show up in the pages. The pageview and its pages do show up.

I have not been able to reproduce the problem in a simple project (the explorerbar idea works fine in the simple project). More strangely I only need to change
RadPageView temp = new RadPageView() { Dock = DockStyle.Fill };
temp.ViewMode = PageViewMode.ExplorerBar;
to
RadPageView temp = new RadPageView() { Dock = DockStyle.Fill };
temp.ViewMode = PageViewMode.Stack;
and the rest of the code in the app creates the correct pages, controls and items and displays them.

Are there any properties I need to set specific to the explorerbar mode which will allow the content of my pages to show when in explorerbar mode?

Have you come across this problem before?

Regards
Ian Carson 

2 Answers, 1 is accepted

Sort by
0
Ian
Top achievements
Rank 1
answered on 19 Dec 2011, 01:54 AM
Hi Telerik

An update on this issue.

We are using the mousedown event with a hit test to commence a drag operation from the tab item so that we can drag the page.Tag object to a tree elsewhere in the app. Using this event is preventing the explorerbar mode from opening the clicked page. The event code looks like this:
private void rpv_MouseDown(object sender, MouseEventArgs e)
{
    RadPageView rpv = sender as RadPageView;
    RadPageViewItem hitItem = rpv.ViewElement.ItemFromPoint(e.Location);
    if (e.Button == MouseButtons.Left && hitItem != null)
    {
        if (rpv.SelectedPage.Tag != null)
        {
            rpv.DoDragDrop(rpv.SelectedPage.Tag, DragDropEffects.Copy);
        }
    }
    if (e.Button == MouseButtons.Right && hitItem != null)
    {
        iLibContextPage = hitItem.Page;
        if (iLibContextPage.Parent.Name == "User Defined")
        {
            Point p = rpv.PointToScreen(e.Location);
            cmUserDefinedInstruments.Show(p.X, p.Y);
        }
    }
    else
    {
        iLibContextPage = null;
    }
}

Is there a way we can modify this code to allow the pageview to expand and collapse on click without having to revisit our drag code? Or do we need to utilise the Telerik drag system? If the answer to this is yes how do we prevent the dragging of pages into different index positions in the pages collection and only allow the drag we need to implement?

Thanks in advance
Regards
Ian Carson 
0
Ivan Todorov
Telerik team
answered on 21 Dec 2011, 12:10 PM
Hi Ian,

Thank you for contacting us.

When you start a drag&drop operation by the DoDragDrop method, the mouse events are not being sent to the control until the operation ends. In your case, you cannot expand the clicked page, because you are starting the drag on the MouseDown event which is the first of the mouse events to be fired.

The following code snippet demonstrates how to implement this case in such a way that all functionality works correctly:
bool isMouseDown = false;
Point dragStartPoint;
 
private void radPageView1_MouseDown(object sender, MouseEventArgs e)
{
    isMouseDown = true;
    dragStartPoint = e.Location;
}
 
private void radPageView1_MouseMove(object sender, MouseEventArgs e)
{
    isMouseDown = (e.Button == System.Windows.Forms.MouseButtons.Left);
    bool isRealDrag = Math.Abs(e.Location.X - dragStartPoint.X) > SystemInformation.DragSize.Width ||
        Math.Abs(e.Location.Y - dragStartPoint.Y) > SystemInformation.DragSize.Height;
 
    if (!isMouseDown || !isRealDrag)
    {
        return;
    }
 
    RadPageView rpv = sender as RadPageView;
    RadPageViewItem hitItem = rpv.ViewElement.ItemFromPoint(e.Location);
    if (e.Button == MouseButtons.Left && hitItem != null)
    {
        hitItem.SetValue(LightVisualElement.IsMouseDownProperty, false);
        if (rpv.SelectedPage.Tag != null)
        {
             
            rpv.DoDragDrop(rpv.SelectedPage.Tag, DragDropEffects.Copy);
        }
    }
}

I hope you find this useful. Feel free to ask if you have any additional questions.

Greetings,
Ivan Todorov
the Telerik teamQ3’11 of RadControls for WinForms is available for download (see what's new). Get it today.
Tags
PageView
Asked by
Ian
Top achievements
Rank 1
Answers by
Ian
Top achievements
Rank 1
Ivan Todorov
Telerik team
Share this question
or