Adicione uma Variavel Global;
1:DimWTLinhaAs Integer
Agora no botão Próximo Registro, adicione:
1:IfWTLinha = NothingThen2: WTLinha = DataGridView1.SelectedCells(0).RowIndex' Aqui pegamos qual linha o usuário selecionou3: WTLinha += 1 4: DataGridView1.CurrentCell = DataGridView1.Rows(WTLinha).Cells(0)' Aqui jogamos para proxima linha5:Else6: WTLinha += 1 7: DataGridView1.CurrentCell = DataGridView1.Rows(WTLinha).Cells(0)' Aqui jogamos para proxima linha8:End If
No botão Voltar é só mudar WTLinha += 1 Para WTLinha -= 1
Para selecionar o primeiro registro;
1: DataGridView1.CurrentCell = DataGridView1.Rows(0).Cells(0)
Para selecionar o ultimo registro;
1:DimCountAs Integer= DataGridView1.Rows.Count -1 2: DataGridView1.CurrentCell = DataGridView1.Rows(Count).Cells(0)
Este método acima é o que eu desenvolvi por conta, porém existe esse outro;
1:'Proximo2:Try3:DimlastRowNumAs Integer= (Me.DataGridView1.Rows.Count - 1 - 1) 4:DimcurDataGridViewRowAsDataGridViewRow = DataGridView1.CurrentRow 5:DimcurRowNumAs Integer= curDataGridViewRow.Index 6:If(curRowNum >= lastRowNum)Then7:Else8:DimnextRowAsDataGridViewRow = DataGridView1.Rows(curRowNum + 1) 9: DataGridView1.CurrentCell = nextRow.Cells(0) 10: nextRow.Selected =True11:End If12:Catch13:End Try14:'Voltar15:DimlastRowNumAs Integer= (Me.DataGridView1.Rows.Count + 1 + 1) 16:DimcurDataGridViewRowAsDataGridViewRow = DataGridView1.CurrentRow 17:DimcurRowNumAs Integer= curDataGridViewRow.Index 18:If(curRowNum >= lastRowNum)Then19:Else20:DimnextRowAsDataGridViewRow = DataGridView1.Rows(curRowNum - 1) 21: DataGridView1.CurrentCell = nextRow.Cells(0) 22: nextRow.Selected =True23:End If
Bom proveito, Abrçs...
muy bueno.. y no necesariamente el ejemplo tiene que poner la conexion a la base de datos.
ResponderExcluirMuito obrigado!
Excluir