Results 1 to 3 of 3

Thread: Move Rows of Datagridview In VB.Net

  1. #1
    Join Date
    Dec 2008
    Posts
    10

    Move Rows of Datagridview In VB.Net

    Hello Friends,

    How can i Move Rows of Datagridview In VB.Net ?
    Actually I am not using this feature in my application but just for some additional knowledge I want to know this.

    Thanks.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: Move Rows of Datagridview In VB.Net

    I can suggest a simple logic,

    Temp = A

    A = B

    B = Temp

    This should swap and will involve one less memory transfer per swap.

  3. #3
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Move Rows of Datagridview In VB.Net

    I have made this sub procedure. Try by using it on Button click event in your code. Hope this will work as per your requirement.


    Code:
    Public Sub MoveUp(ByRef firstRow As System.Windows.Forms.DataGridViewRow, ByRef nextRow As System.Windows.Forms.DataGridViewRow)
            'Create a temporary value
            Dim temp As Object
            Dim temp2 As Object
    
            'Loop through each cell in the firstRow datagridview
            Dim i As Integer
            For i = 0 To firstRow.Cells.Count - 1
                'If the cell isn't read only, then swap them.
                If firstRow.Cells(i).ReadOnly = False Then
                    'use the temp object to swap the cell values.
                    temp = firstRow.Cells(i).Value
                    temp2 = nextRow.Cells(i).Value
    
                    firstRow.Cells(i).Value = temp2
                    nextRow.Cells(i).Value = temp
                End If
            Next
        End Sub

Similar Threads

  1. How to use datagridview readonly cell
    By Ground 0 in forum Windows Software
    Replies: 3
    Last Post: 29-07-2009, 12:44 PM
  2. Replies: 2
    Last Post: 09-07-2009, 08:57 AM
  3. .net datagridview mouse position
    By Jevin in forum Software Development
    Replies: 2
    Last Post: 29-06-2009, 06:12 PM
  4. How to resize cell in DataGridView
    By Ebadaah in forum Software Development
    Replies: 3
    Last Post: 10-06-2009, 06:54 PM
  5. Difference Between DataGrid and DataGridView In VB.Net
    By Gallard in forum Software Development
    Replies: 3
    Last Post: 17-01-2009, 05:08 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,915,120.65639 seconds with 17 queries