I have an SQL Query for price that displays it on a DataGridView with decimals for example (500.00) but the original datatype of the price column is an integer so I had to concatinate in on the SQL Query. The case is when I am getting the value from the DataGridView to a TextBox it gets the whole value with the decimals to the TextBox. What I wish to happen is that it ignores the decimals and only gets the whole number of the price. (500.00 - DataGridView) (500 - TextBox)
Here is my code:
Private Sub BilliardItemGrid_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles BilliardItemGrid.CellClick // this is the DataGridView Cell Click function
If e.RowIndex >= 0 Then
Dim row As DataGridViewRow
row = Me.BilliardItemGrid.Rows(e.RowIndex)
Inventory.load_itemtypebilliard(Inventory_EditBothItem.ComboBox1)
Inventory_EditBothItem.TextBox3.Text = row.Cells("ID").Value.ToString
Inventory_EditBothItem.TextBox1.Text = row.Cells("Barcode ID").Value.ToString
Inventory_EditBothItem.Label16.Text = row.Cells("Barcode ID").Value.ToString
Inventory_EditBothItem.TextBox2.Text = row.Cells("Name").Value.ToString
Inventory_EditBothItem.ComboBox3.Text = "Billiard"
Inventory_EditBothItem.Label18.Text = "Billiard"
Inventory_EditBothItem.ComboBox1.Text = row.Cells("Type").Value.ToString
Inventory_EditBothItem.Label17.Text = row.Cells("Type").Value.ToString
Inventory_EditBothItem.TextBox4.Text = row.Cells("Price").Value.ToString // this is how I get the value of the price from the DataGridView to a TextBox
Inventory_EditBothItem.Label15.Text = row.Cells("Price").Value.ToString // this is how I get the value of the price from the DataGridView to a Label
Inventory_EditBothItem.TextBox5.Text = row.Cells("Quantity").Value.ToString
Inventory_EditBothItem.TextBox6.Text = row.Cells("Critical").Value.ToString
Inventory_EditBothItem.DateTimePicker1.Text = row.Cells("Date Modified").Value.ToString
Inventory_EditBothItem.ComboBox2.Text = row.Cells("Status").Value.ToString
Inventory_EditBothItem.TextBox8.Text = row.Cells("Description").Value.ToString
Inventory.load_givenid()
End If
If Inventory_EditBothItem.TextBox1.Text = Nothing Then
MetroMessageBox.Show(Me, "Select a Billiard Item First", "System Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
Inventory_EditBothItem.ShowDialog()
If Inventory_EditBothItem.Visible = False Then
Inventory.load_billiarditemtable(BilliardItemGrid)
Inventory.load_bowlingitemtable(BowlingItemGrid)
Inventory.load_allitemtable(AllItemGrid)
Store.load_itemstoretable(ItemStoreGrid)
Reports.load_itemlisttable(ItemTransactionGrid, ItemTransactionComboBoxInDemand)
Reports.load_audittable(AuditGrid, AuditComboBoxUser, AuditComboBoxType, AuditDateTimePicker1, AuditDateTimePicker2, AuditRadioButtonAll, AuditRadioButtonSpecDate)
End If
End If
End Sub
Try converting to an Integer.
Inventory_EditBothItem.TextBox4.Text = CInt(row.Cells("Price").Value).ToString
Inventory_EditBothItem.Label15.Text = CInt(row.Cells("Price").Value).ToString
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments