-
June 12th, 2015, 05:28 AM
#1
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
Code:
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
DR.Read()
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
Else
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|