We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Drag and Drop into Grid

Thread ID:





11634 Mar 12,2004 07:10 AM UTC Mar 12,2004 09:11 AM UTC WinForms 1
Tags: GridControl
Kai Wachter
Asked On March 12, 2004 07:10 AM UTC

Hi everybody, I have the following scenario: one tree and one grid The Nodes of the tree must be dropped into the grid, but a drop is not allowed everywhere. Is there a possibility to validate during drag which coordinates (row, col) the cell under the cursor has? i tried it with Private Sub GridControl1_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles GridControl1.DragOver e.Effect = Windows.Forms.DragDropEffects.All Dim lrange As GridRangeInfo lrange = GridControl1.PointToRangeInfo(New System.Drawing.Point(e.X, e.Y)) Me.GridControl1.Selections.SelectRange(lrange, True) End Sub But allways the last cell is selected. Thanks for your help. regards. kai

Administrator [Syncfusion]
Replied On March 12, 2004 09:11 AM UTC

There is a problem in using Windows Forms Drag events with the grid. The problem is that the grid also has some objects that listen to these events, and there is no guarantee your listener will be hit before/after the grid''s listener. So, there is no way to ''know'' whose settings are going to take effect when several listeners subscribe to the same event. This is a generic Windows Forms events problem, and is one of the negatives (or positives depending on your point of view???) to the event architecture. One solution to this problem is to not use events, but to derive the control and override the accopanying OnEventXXXX method that, by convention, is provided by the Framework. This way, you can control what setting is returned. Below is code that does not let you drop on row 3. (The range indicator frame will not move into row 3). Protected Overrides Sub OnDragOver(drgevent As System.Windows.Forms.DragEventArgs) Dim pt As Point = Me.PointToClient(New Point(drgevent.X, drgevent.Y)) Dim row, col As Integer If Me.PointToRowCol(pt, row, col, 1) Then If row = 3 Then drgevent.Effect = DragDropEffects.None Return End If End If MyBase.OnDragOver(drgevent) End Sub ''OnDragOver


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon