List Box or Combo Box with Database

jace314

Member
Joined
Nov 2, 2005
Messages
17
Location
CT
Programming Experience
Beginner
Im working on an application for a POS system. Im starting off slow and I have a database with 4 tables in it currently.
Im at the point where I have the details of the table (inventory) on the form, and working fine. I have a row thats called DeptId which I want it to use a drop down box to select the name of the dept from the Dept Table. How do I go about doing this. I got a listbox to show the dept names from the dept table, but how do i save the info into the inventory table?
Thanks
 
Ok, i think there is three questions there so i'll approach them one at a time.

I'm assuming your using OLEDB by the way
drag a combobox onto yuor form and set it's datasource property to the department datatable. then set it's displaymember to the field of the datatable you want.
To save the info you must modify the datatable as required then call the update method of the dataadapter.

guess there was only two questions there afterall, oh well...
 
Thanks, I am now able to view the data in the combo box, from the other table. By using the datasource for the combo box, and the display member. What would be the code to save the info from the combo box, back to the current table? I have no idea. This is the code I have for the save button, which is currently saving everything fine, except of course the combo box info, which always appears as the first choice from the box...
VB.NET:
Public Class Form5
Private Sub InventoryBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InventoryBindingNavigatorSaveItem.Click
Me.Validate()
Me.InventoryBindingSource.EndEdit()
Me.InventoryTableAdapter.Update(Me.WMSDataSet2.Inventory)
End Sub

Thanks, again
 
ANSWERED - List or combo-box

I figured it out right after I posted! I went to the properties for the combo-box, and set the databindings - text, to the proper column from the table and set it upon validation. All worked well, and also figured out a couple other things on the way! Thanks for leading me in the right direction!
 
Back
Top