hi there,
hopefully the title is clear enough - what im trying to achieve is create an invoice form where the user can fill in the cells in the datagridview like Qty, Code, Description and price.
Qty is a textbox - user enter value manually
Code is a combobox - user pick a value from the list (combobox is bind to a datasource)
Description is a textbox - fill automatically based on combobox selection (code) - bind to same datasource
Price is a textbox - fill automatically based on combobox selection (code) - bind to same datasource
here is my code - im able to select the value in the combobox, but the description and price are not populating. Any idea why ?
Thank you for your help
hopefully the title is clear enough - what im trying to achieve is create an invoice form where the user can fill in the cells in the datagridview like Qty, Code, Description and price.
Qty is a textbox - user enter value manually
Code is a combobox - user pick a value from the list (combobox is bind to a datasource)
Description is a textbox - fill automatically based on combobox selection (code) - bind to same datasource
Price is a textbox - fill automatically based on combobox selection (code) - bind to same datasource
here is my code - im able to select the value in the combobox, but the description and price are not populating. Any idea why ?
VB.NET:
Dim bindingpart As New BindingSource()
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|dbServauto.mdb"
con.Open()
sqlP = "SELECT * from tblParts"
daParts = New OleDb.OleDbDataAdapter(sqlP, con)
daParts.Fill(dspart, "Parts")
bindingpart.DataSource = dspart.Tables("Parts")
'dgFactures.DataSource = bindingpart
con.Close()
End sub
VB.NET:
Private Sub dgFactures_SelectionChanged(sender As Object, e As EventArgs) Handles dgFactures.SelectionChanged
With colCode
.DataSource = bindingpart
.DisplayMember = "Code"
.ValueMember = "Code"
End With
'retrieve data from bindingsource for the textbox Description and Price
colDesc.DataGridView.DataBindings.Add(New Binding("text", bindingpart, "Description"))
colDesc.DataGridView.DataBindings.Clear()
colPrice.DataGridView.DataBindings.Add(New Binding("text", bindingpart, "Price"))
colPrice.DataGridView.DataBindings.Clear()
End Sub
Thank you for your help