Declined
Last Updated: 06 Nov 2018 12:29 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 29 Oct 2018 09:03
Category: TreeView
Type: Bug Report
1
FIX. RadTreeView - incorrect rendering of a message box when shown in the TreeViewElement.DragDropService.PreviewDragDrop event
To reproduce: please refer to the attached sample project and try to reorder a node. You will notice that the message box is not rendered properly.

        //case 2
        private void DragDropService_PreviewDragDrop(object sender, RadDropEventArgs e)
        {
             e.Handled = true;
            RadMessageBox.Show(this, "Showing a messagebox under dragending doesn't work correctly.");
        }

        //case 1
        private void radTreeView1_DragEnding(object sender, Telerik.WinControls.UI.RadTreeViewDragCancelEventArgs e)
        {
            //e.Cancel = true;
            //RadMessageBox.Show(this, "Showing a messagebox under dragending doesn't work correctly.");
        }

Workaround: subscribe to the TreeViewElement.DragDropService.PreviewDragDrop and set the Handled argument to true if you want to cancel the drop operation. Then, handle the TreeViewElement.DragDropService.Stopped event and show the desired message.

        public Form1()
        {
            InitializeComponent();
            
            this.radTreeView1.TreeViewElement.DragDropService.PreviewDragDrop += DragDropService_PreviewDragDrop;
            this.radTreeView1.TreeViewElement.DragDropService.Stopped+=DragDropService_Stopped;
        }

        private void DragDropService_Stopped(object sender, EventArgs e)
        {
            
            RadMessageBox.Show(this, "Showing a messagebox under dragending doesn't work correctly.");
        }
 
        private void DragDropService_PreviewDragDrop(object sender, RadDropEventArgs e)
        {
            e.Handled = true;
        }
1 comment
ADMIN
Ivan Petrov
Posted on: 02 Nov 2018 15:10
The drag drop service of RadTreeView handles/intercepts mouse messages at a very low level. Showing a dialog window such as a message box creates a new window and thus includes another entity that wants to get window messages. The same window messages the drag drop service intercepts. When showing a window by providing it's win32 owner the messages are sort of shared between the parent and the child form. This causes the message box to behave strangely in this case. The way to show the message box here is to call the Show method without providing a win32 owner, which means to use an overload of the Show method without that parameter.