Language: VB.NET
DataGridView
1: Private Sub btnAdd_Click(ByVal sender As System.Object, _ 2: ByVal e As System.EventArgs) Handles btnAdd.Click 3: 4: ' Check that the line item data is valid 5: If IsValidLineItem() Then 6: 7: ' Add a new row to the InvoiceLineItems table 8: InvoiceLineItemsBindingSource.AddNew() 9: 10: ' Set the values of the row in the data grid 11: Dim rowIndex As Integer = InvoiceLineItemsDataGridView.Rows.Count - 1 12: Dim row As DataGridViewRow _ 13: = InvoiceLineItemsDataGridView.Rows(rowIndex) 14: Dim cell As DataGridViewCell 15: cell = row.Cells(0) 16: cell.Value = 1 17: invoiceSequence += 1 18: cell = row.Cells(1) 19: cell.Value = invoiceSequence 20: cell = row.Cells(2) 21: cell.Value = AccountNoComboBox.SelectedValue 22: cell = row.Cells(3) 23: cell.Value = AccountNoComboBox.Text 24: cell = row.Cells(4) 25: cell.Value = DescriptionTextBox.Text 26: cell = row.Cells(5) 27: cell.Value = AmountTextBox.Text 28: 29: ' Save the line item to the table 30: InvoiceLineItemsBindingSource.EndEdit() 31: 32: ' Calculate the invoice total 33: Me.GetInvoiceTotal() 34: 35: ' Prepare for the next entry 36: DescriptionTextBox.Text = "" 37: AmountTextBox.Text = "" 38: DescriptionTextBox.Select() 39: 40: End If 41: End Sub
Report Abuse
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search

