I have found several sources that suggest using the GiveFeedback Event to be able to do custom cursors while dragging into a component. I have successfully used this approach with ListBoxes, but it doesn't work with a TreeView. The GiveFeedback Event seems not to be fired for the TreeView. Any suggestions.
Thanks,
Curt
Thanks,
Curt
VB.NET:
Private Sub TreeViewSections_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TreeViewSections.DragEnter
If e.Data.GetDataPresent(DataFormats.Text) Then
e.Effect = DragDropEffects.Copy
Dim temp As String = "asadd"
drawcursor(CStr(e.Data.GetData(temp.GetType)), TreeViewSections.Font)
Else
e.Effect = DragDropEffects.None
End If
End Sub
Private Sub TreeViewSections_GiveFeedback(ByVal sender As Object, ByVal e As GiveFeedbackEventArgs) Handles TreeViewSections.GiveFeedback
e.UseDefaultCursors = False
Windows.Forms.Cursor.Current = textcursor
End Sub
Sub drawcursor(ByVal text As String, ByVal fnt As Font)
Dim bmp As New Bitmap(1, 1)
Dim g As Graphics = Graphics.FromImage(bmp)
Dim sz As SizeF = g.MeasureString(text, fnt)
bmp = New Bitmap(CInt(sz.Width), CInt(sz.Height))
g = Graphics.FromImage(bmp)
g.Clear(Color.White)
g.DrawString(text, fnt, Brushes.Black, 0, 0)
g.Dispose()
textcursor = New Cursor(bmp.GetHicon)
bmp.Dispose()
End Sub
Dim textcursor As Cursor