Home Forums WinForms controls Xceed Grid for WinForms Auto total in onecolumn after value change in another

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #14617 |

    Hi All

    Not so brite here hehehe, battling with this code, the rest works fine but I do not understand or maybe just missing something.

    Me.oleDbInsertCommand.CommandText = “INSERT INTO tblFishingDetails(resdetID, tripID, [Time], Species………………… [Feed/Chum], Lure, Total) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)”

    Me.oleDbInsertCommand.Connection = Me.oleDbConnection
    Me.oleDbInsertCommand.Parameters.Add(New …………………..
    Me.oleDbInsertCommand………………

    Me.oleDbInsertCommand.Parameters.Add(New OleDbParameter(“Landed”, OleDbType.Boolean, 2, “Landed”))

    Me.oleDbInsertCommand.Parameters.Add(New
    Me.oleDbInsertCommand.

    Me.oleDbInsertCommand.Parameters.Add(New OleDbParameter(“Total”, OleDbType.VarWChar, 40, “Total”))

    My problem I have is to get “1” added to the “TotalFish” column everytime the “Landed” column is checked as true. The suggested code is below, that which is commented out is wrong I know and need help with it please

    ‘AddHandler dataRowTemplate1.Cells(0).LeavingEdit, AddressOf column2_LeaveEdit

    Private Sub Landed_CheckedChanged(ByVal sender As Object, ByVal e As Xceed.Grid.LeavingEditEventArgs

    Dim r As Xceed.Grid.DataRow
    For Each r In Form1Grid.DataRows
    If r.Cells(0).Value = True Then
    ‘If LandedCheckBox.Checked = True Then
    ‘If TotalFishCell.Text = “” Then
    ‘TotalFishCell.Text = “1”
    Else
    ‘TotalFishCell.Text = (CInt(TotalFishTextBox.Text) + 1)ToString()
    End If

    Next
    End Sub

    All help would be greatly appreciated as the whole program runs smoothly except for this part in the grid. On the form version it is no problem and works fine.

    Thanks again

    Imported from legacy forums. Posted by Andre (had 1882 views)

    User (Old forums)
    Member
    Post count: 23064

    You can do something like this, in my test I added 2 columns, one was of type bool and the other of type int :

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    AddHandler dataRowTemplate1.Cells(0).LeavingEdit, AddressOf column2_LeaveEdit

    Dim row = GridControl1.DataRows.AddNew()
    row = GridControl1.DataRows.AddNew()
    row = GridControl1.DataRows.AddNew()
    row = GridControl1.DataRows.AddNew()
    row = GridControl1.DataRows.AddNew()
    row = GridControl1.DataRows.AddNew()
    row = GridControl1.DataRows.AddNew()
    row = GridControl1.DataRows.AddNew()

    End Sub

    Private Sub column2_LeaveEdit(ByVal sender As Object, ByVal e As Xceed.Grid.LeavingEditEventArgs)
    System.Diagnostics.Debug.WriteLine(“Leaving”)

    Dim r As Xceed.Grid.DataRow

    For Each r In GridControl1.DataRows

    If r.Cells(0).Value = True Then

    ‘…

    End If

    Next

    Imported from legacy forums. Posted by Matt (had 2999 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.