Jose wrote:
[color=blue]
>How obtain the current record in the datagrid? The idea is doubleclick and
>show another form with this current recor of my datagrid.
>
>Thanks a lot
>
>
>
>[/color]
Use the underlying data source instead.
For starters, you need an easy way to reference what is currently
selected on the datagrid control. Start with something like this:
=============== =============== =============== =============== ==
Private Sub dgvBranches_Cur rentCellChanged (ByVal sender As Object,
ByVal e As System.EventArg s) Handles dgvBranches.Cur rentCellChanged
Try
'Determine which row and column selected and
'display contents of cells in proper text boxes.
CurrentRow = dgvBranches.Cur rentCell.RowNum ber
CurrentColumn = dgvBranches.Cur rentCell.Column Number
ShowTheCells()
Catch ex As Exception
LogErrors(ex, " In frmMain_dgvBran ches_CurrentCel lChanged")
End Try
End Sub
=============== =============== =============== =============== ===
Once you have that settled then you can do things like passing values
into text boxes and such. There is a lot of formatting in this example
since I wanted to make sure that everything looked good and would save
in a consisten format in the database. Here is an example:
If dgvBranches.Ite m(CurrentRow, 4) = "True" Then
cbxActive.Check ed = True
ElseIf dgvBranches.Ite m(CurrentRow, 4) = "False" Then
cbxActive.Check ed = False
End If
Dim i As Integer
For i = 0 To myDataSet.Table s("MySQL Branches").Rows .Count
- 1
If dgvBranches.Ite m(CurrentRow, 0) =
myDataSet.Table s("MySQL Branches").Rows (i).Item(0) Then
txtStreet.Text = StrConv(myDataS et.Tables("MySQ L
Branches").Rows (i).Item(2), VbStrConv.Prope rCase)
txtZip.Text = myDataSet.Table s("MySQL
Branches").Rows (i).Item(3)
txtCity.Text = StrConv(myDataS et.Tables("MySQ L
Branches").Rows (i).Item(4), VbStrConv.Prope rCase)
txtState.Text = StrConv(myDataS et.Tables("MySQ L
Branches").Rows (i).Item(5), VbStrConv.Upper Case)
txtPhone.Text = myDataSet.Table s("MySQL
Branches").Rows (i).Item(6)
txtFax.Text = myDataSet.Table s("MySQL
Branches").Rows (i).Item(7)
txtConFirst.Tex t = StrConv(myDataS et.Tables("MySQ L
Branches").Rows (i).Item(8), VbStrConv.Prope rCase)
txtConLast.Text = StrConv(myDataS et.Tables("MySQ L
Branches").Rows (i).Item(9), VbStrConv.Prope rCase)
txtBranchEmail. Text =
StrConv(myDataS et.Tables("MySQ L Branches").Rows (i).Item(10),
VbStrConv.Upper Case)
End If
Next
Catch ex As Exception
LogErrors(ex, " In ShowTheCells()" )
End Try
"tomb" does have a good point about using the underlying data though.
I think you would have to use the currency manager to accomplish that
one. Hope this helps.
Comment