CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 1 of 1
  1. #1
    Join Date
    May 2008

    Unhappy How to move cursor into certain cell Datagridview

    Dear all members,

    I am writing small application using Datagridview in VB.Net

    What i want is I want to move to earlier cell after the cell was edited.

    Below is my code that I have done

    Private Sub DGV1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV1.CellEndEdit
            Dim flag_cell_edited As Boolean
            Dim CurrentRow As Integer
            Dim CurrentColumn As Integer
            If e.ColumnIndex = 0 Then
                flag_cell_edited = True
                CurrentRow = e.RowIndex
                CurrentColumn = e.ColumnIndex
                Call Koneksi()
                CMD = New OleDbCommand("Select Nama_Matakuliah, SKS from tbmatakuliah where Kode_MK = '" & DGV1.Rows(e.RowIndex).Cells(0).Value & "' and Program_Studi = '" & txt_ps.Text & "'", CONN)
                DR = CMD.ExecuteReader
                If DR.HasRows Then
                    DGV1.Rows(e.RowIndex).Cells(1).Value = DR.Item("Nama_Matakuliah")
                    DGV1.Rows(e.RowIndex).Cells(2).Value = DR.Item("SKS")
                    DGV1.Rows(e.RowIndex).Cells(1).ReadOnly = True
                    DGV1.Rows(e.RowIndex).Cells(2).ReadOnly = True
                    DGV1.Rows(e.RowIndex).Cells(3).Selected = True
                    MsgBox("Kode Mata Kuliah " & DGV1.Rows(e.RowIndex).Cells(0).Value & " Tidak ditemukan", MsgBoxStyle.OkOnly, "Pengisian Kartu Hasil Studi")
                    DGV1.CurrentCell = DGV1(CurrentColumn, CurrentRow)
                    flag_cell_edited = False
                End If
            End If
        End Sub
    But the cursor will not move to the earlier cell I mean.

    Please help me..
    Last edited by HanneSThEGreaT; June 14th, 2015 at 01:30 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width