Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Datagrid

Datagrid

Scheduled Pinned Locked Moved Visual Basic
salestutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sohil masani
    wrote on last edited by
    #1

    I have use a datagrid in my sales software, now when the user select any item and qty i want to calculate its value in another columns. say for example: Col "Items" Col "Qty" Col "Rate" Col "Total Value" - I want to calculate the total value. Thanks, Sohil Masani

    P M 2 Replies Last reply
    0
    • S sohil masani

      I have use a datagrid in my sales software, now when the user select any item and qty i want to calculate its value in another columns. say for example: Col "Items" Col "Qty" Col "Rate" Col "Total Value" - I want to calculate the total value. Thanks, Sohil Masani

      M Offline
      M Offline
      Mr Oizo
      wrote on last edited by
      #2

      Here is a code snippet that I found online a while ago that helps: Try this code in DataGrid CellEndEdit Events (note: this will sum the items not multiply. So you will just modify it to check whether the cells have values and then multiply the values. i am to lazy to retype it)

      Dim iTotal As Integer = 0
      With DataGrid1
      For i As Integer = 0 To .ColumnCount - 2
      If Not IsDBNull(.Rows(e.RowIndex).Cells(i).Value) Then
      iTotal += .Rows(e.RowIndex).Cells(i).Value
      End If
      Next
      .Rows(e.RowIndex).Cells(.ColumnCount - 1).Value = iTotal
      End With

      modified on Wednesday, January 27, 2010 2:59 AM

      1 Reply Last reply
      0
      • S sohil masani

        I have use a datagrid in my sales software, now when the user select any item and qty i want to calculate its value in another columns. say for example: Col "Items" Col "Qty" Col "Rate" Col "Total Value" - I want to calculate the total value. Thanks, Sohil Masani

        P Offline
        P Offline
        Paramu1973
        wrote on last edited by
        #3

        Hi Sohil, You can use the Datagridview_CellEndEdit() for manipulating the calculations. For example, from the below, suppose your "qty" column number is 3 or your "rate" column is 4 then, it can be...like the following Private Sub MyDataGrid1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles MyDataGrid1.CellEndEdit If e.ColumnIndex = 3 or e.columnIndex = 4 Then Try MyDataGrid1.CurrentRow.Cells("total value").Value = MyDataGrid1.CurrentRow.Cells("qty").Value * MyDataGrid1.CurrentRow.Cells("rate").Value Catch ex As Exception End Try End If End Sub

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups