S
H
A
R
E
Showing posts with label DataGridView. Show all posts
Showing posts with label DataGridView. Show all posts

Friday, July 15, 2011

Auto Sort in DataGridView From DataSet (Sorting, Selecting, Finding)

Auto Sort in DataGridView From DataSet 1
Find Row Match Like with TextBox


Read More!

Sunday, April 17, 2011

VB.net DataGridView, Move Row Item By Draging






Download Source (VB.net 2010)


This a sample code how to moving DataGridView rows item with drag and droping, you can move item to every line, check it!

I using this code for get the index of rows where user droping a data:

Private Sub DataGridView1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DataGridView1.DragDrop

        Dim CP As Point = DataGridView1.PointToClient(New Point(e.X, e.Y))

        Dim RowDestination As Integer = DataGridView1.HitTest(CP.X, CP.Y).RowIndex

        Dim RowSource As Integer = e.Data.GetData("System.String")

        If RowDestination >= 0 Then

            Dim tmp(0 To DataGridView1.Rows(0).Cells.Count - 1)

            'saving Cells

            For i = 0 To tmp.Count - 1

                tmp(i) = DataGridView1.Rows.Item(RowSource).Cells(i).Value

            Next



            DataGridView1.Rows.RemoveAt(RowSource)

            DataGridView1.Rows.Insert(RowDestination, 1)

            'Aplly Saved Cells

            For i = 0 To tmp.Count - 1

                DataGridView1.Rows(RowDestination).Cells(i).Value = tmp(i)

            Next i

            DataGridView1.Rows(RowDestination).Selected = True

        End If

    End Sub
Read More!