Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Questions about loading and working with datagrids

Status
Not open for further replies.

jasperjasper

Programmer
Mar 23, 2004
117
US
Its easy to fill a datagrid, but I want to do more. I want to read the data in the grid and sum the amount columns...
I want to process the records in a loop...However I used a dataset to Fill the grid...How do you get control of the data and the grid...it was easy in vb6/ADO....
 
On another note, what about clicking on a row of the grid,
in order to do something. Is there a thread on that ....

Thanks
 
I created some code to sum two columns of a datagrid.

Public Sub totalhours()
'Calculated the Total Column for time worked
Dim TotalTime As Double
Dim QtyPacked As Integer
Dim TimeEach As Integer


'Computes the Total hours cell in the datagrid
Try


If Not IsDBNull(dgPacking.Item(dgPacking.CurrentRowIndex, 3)) _
And Not IsDBNull(dgPacking.Item(dgPacking.CurrentRowIndex, 2)) Then

'dgPacking.Item(dgPacking.CurrentRowIndex, 2) = TDBTimeEach.Value
'dgPacking.Item(dgPacking.CurrentRowIndex, 3) = TDBDQtyPacked.Value

TimeEach = dgPacking.Item(dgPacking.CurrentRowIndex, 2)
QtyPacked = dgPacking.Item(dgPacking.CurrentRowIndex, 3)

TotalTime = (QtyPacked * TimeEach) / 60

dgPacking.Item(dgPacking.CurrentRowIndex, 4) = Math.Round(TotalTime, 2)

btnSave.Enabled = True
End If
Catch ex As Exception
Throw ex
MsgBox(ex.Message)
End Try
End Sub


I've been working with Datagrid alot, if you have any questions just make sure you clearly explain what you want.
Hook it with at star it this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top