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's a Control without the mentioned bug.

Set `AllowUserToOrderRows` and `AllowDrop` to `True` in the Windows Forms Designer and drag the row headers, not the content.

```
Imports System.ComponentModel

Public Class BetterDataGridView
    Inherits DataGridView

    <Category("Behavior"), DefaultValue(False)>
    Public Property AllowUserToOrderRows As Boolean = False

    Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
        MyBase.OnMouseDown(e)

        Dim hitInfo As HitTestInfo = HitTest(e.X, e.Y)
        If AllowUserToOrderRows AndAlso
                e.Button = MouseButtons.Left AndAlso
                hitInfo.ColumnIndex = -1 AndAlso
                ValidRow(hitInfo.RowIndex) Then
            DoDragDrop(Rows(hitInfo.RowIndex), DragDropEffects.Move)
        End If
    End Sub

    Protected Overrides Sub OnDragOver(e As DragEventArgs)
        MyBase.OnDragOver(e)

        Dim dragRow As DataGridViewRow = e.Data.GetData(GetType(DataGridViewRow))
        Dim targetIndex As Integer = GetRowIndex(e)
        e.Effect = If(ValidRowDragDrop(dragRow, targetIndex),
                      DragDropEffects.Move,
                      DragDropEffects.None)
    End Sub

    Protected Overrides Sub OnDragDrop(e As DragEventArgs)
        MyBase.OnDragDrop(e)

        Dim dragRow As DataGridViewRow = e.Data.GetData(GetType(DataGridViewRow))
        Dim targetIndex As Integer = GetRowIndex(e)

        If e.Effect = DragDropEffects.Move AndAlso ValidRowDragDrop(dragRow, targetIndex) Then
            EndEdit()

            Rows.Remove(dragRow)
            Rows.Insert(targetIndex, dragRow)

            ClearSelection()
            dragRow.Selected = True
        End If
    End Sub

    Protected Function ValidRow(rowIndex As Integer) As Boolean
        Return rowIndex >= 0 AndAlso
            rowIndex < Rows.Count - If(AllowUserToAddRows, 1, 0)
    End Function

    Protected Function GetRowIndex(e As DragEventArgs) As Integer
        Dim clientPos As Point = PointToClient(New Point(e.X, e.Y))
        Return HitTest(clientPos.X, clientPos.Y).RowIndex
    End Function

    Protected Function ValidRowDragDrop(dragRow As DataGridViewRow, targetIndex As Integer) As Boolean
        Return dragRow IsNot Nothing AndAlso
            ValidRow(targetIndex) AndAlso
            targetIndex <> dragRow.Index AndAlso
            Rows.Contains(dragRow)
    End Function
End Class

```
Thank you for everything, code working. I was getting only one error. I solved it.

if the datagridview "Enable Editing" is set, you receive an error when you throw line spacing. You can try. I solved it as follows:

```
    Private Sub DataGridView1(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 = CType(e.Data.GetData(GetType(DataGridViewRow)), DataGridViewRow)

                        If dragIndex = DataGridView1.RowCount - 1 Then '**ADD THIS AREA**
                            DataGridView1.Rows.RemoveAt(fromIndex)
                            DataGridView1.Rows.Insert(DataGridView1.RowCount - 1, dragRow)
                        Else
                            If dragIndex < 0 Then dragIndex = DataGridView1.RowCount - 2 '**this is important**
                            DataGridView1.Rows.RemoveAt(fromIndex)
                            DataGridView1.Rows.Insert(dragIndex, dragRow)
                        End If
                    End If
End Sub

```

Thanks for all other information