Question: I'm compiling a program on gcc by using `-Wbad-function-cast` flag. The gcc show the following warning: 

`cast does not match function type`

this is line of warning: `int ret = (int)`[`FindExecutable(file, NULL, result)`](http://msdn.microsoft.com/en-us/library/windows/desktop/bb776419%28v=vs.85%29.aspx)

The question is: it's possible remove it? maybe casting to another windows data type, but that I handling it as an integer.

Answer: 
Here is a vb version from this C# answer: [How could I Drag and Drop DataGridView Rows under each other?](https://stackoverflow.com/a/1623968/719186)

The form class variables:

```
Private fromIndex As Integer
Private dragIndex As Integer
Private dragRect As Rectangle

```

The drag events:

```
Private Sub DataGridView1_DragDrop(ByVal sender As Object, _
                                   ByVal e As DragEventArgs) _
                                   Handles DataGridView1.DragDrop
  Dim p As Point = DataGridView1.PointToClient(New Point(e.X, e.Y))
  dragIndex = DataGridView1.HitTest(p.X, p.Y).RowIndex
  If (e.Effect = DragDropEffects.Move) Then
    Dim dragRow As DataGridViewRow = e.Data.GetData(GetType(DataGridViewRow))
    DataGridView1.Rows.RemoveAt(fromIndex)
    DataGridView1.Rows.Insert(dragIndex, dragRow)
  End If
End Sub

Private Sub DataGridView1_DragOver(ByVal sender As Object, _
                                   ByVal e As DragEventArgs) _
                                   Handles DataGridView1.DragOver
  e.Effect = DragDropEffects.Move
End Sub

```

The mouse events:

```
Private Sub DataGridView1_MouseDown(ByVal sender As Object, _
                                    ByVal e As MouseEventArgs) _
                                    Handles DataGridView1.MouseDown
  fromIndex = DataGridView1.HitTest(e.X, e.Y).RowIndex
  If fromIndex > -1 Then
    Dim dragSize As Size = SystemInformation.DragSize
    dragRect = New Rectangle(New Point(e.X - (dragSize.Width / 2), _
                                       e.Y - (dragSize.Height / 2)), _
                             dragSize)
  Else
    dragRect = Rectangle.Empty
  End If
End Sub

Private Sub DataGridView1_MouseMove(ByVal sender As Object, _
                                    ByVal e As MouseEventArgs) _
                                    Handles DataGridView1.MouseMove
  If (e.Button And MouseButtons.Left) = MouseButtons.Left Then
    If (dragRect <> Rectangle.Empty _
    AndAlso Not dragRect.Contains(e.X, e.Y)) Then
      DataGridView1.DoDragDrop(DataGridView1.Rows(fromIndex), _
                               DragDropEffects.Move)
    End If
  End If
End Sub

```

Make sure you have the grids `AllowDrop` property set to true.
1.5 improvements for the event *GridView.DragDrop*:

1. The first 50% improvement, To avoid the descriped error you can also use 

```
Private Sub DgvSearchFieldCurrent_DragDrop( _
   ByVal sender As  Object, ByVal e As DragEventArgs) _
   Handles DgvSearchFieldCurrent.DragDrop

Dim LclDgv As DataGridView = CType(sender, DataGridView)

If dragIndex > -1 AndAlso dragIndex < LclDgv.RowCount -1 Then

```
2. Second is to set focus to the current row and the first cell:

```
LclDgv.Rows.Insert(dragIndex, dragRow)

LclDgv.Rows(fromIndex).Selected = False
LclDgv.Rows(dragIndex).Selected = True

For Each C As DataGridViewColumn In LclDgv.Columns
  LclDgv(C.Index, fromIndex).Selected = False
Next

LclDgv(0, dragIndex).Selected = True

```