Presenter:Beth Massi
Visual Basic programmers will see how to set up binding to a list of lookup values using a combobox as well as how to use a combobox in a grid.
Click here to go to original video page
Minute 0
Hi my name is Beth Massey welcome to the Windows forms of her data video series and this next video were going to be creating a data entry form at the lookup lists some is a wanted display a list of values tour users to select from but only store the key into our table ipomoea before and keep the reference table for instance I m going to show you how to create one of these lookup list using a combo box as well as using it box inside of a gray in the previous videos we created a database called on mass and a application called the order manager and I have that open now so the first or going to do is rely to create a new floor so I m going to right click on the project select add and select Windows form and word is getting a bit form for sale there were going to do is connect to our data so I m going to go the menu select data and show data sources missile at the data sources window noticed I have a few data sets in here already given for
Minute 1
And a lot of the previous videos we been creating forms of data sets sought is going to add another one now so will select add new data source cheese databases and data source type we use the current connection string in the party set up this form is going to be editing the orders so I m going to be selecting our order header and the order details onto this form so go tables select order detail in orders and I will name the data set orders data set so now just going to drag he orders as the details onto our form here and then you ll notice I ll select the order detail as the great below on keeping mind that we have in order detail here at a
Minute 2
This level in our data set and also at its relation level we want to make sure that we always select a related order detail that will give us the automatic filtering as we stroll through our orders Sony just set the anchor property here on our grid and get this out of the way and make the form of a little bit better than also going to edit columns here and we are going to just remove these to hear and pay and pay next are going to add our lookups so I m going to add another data source click on add new data sources select database use the connection string we set up and I m going to select products this time so what I want to do is create a list of products to show in upgrade but actually I don t want to select the entire
Minute 3
Cable products are useless selected name and the product ID Summit call this products look up the so the reason why we put the products look up inside of another data set is now it s going to be easier for us to use this data set on other forms so that what I do is for going to go to your toolbox and were going to drop a binding source into the component tray and we re going to name its product line in source today and I m going to select for the data source really going to other data sources and we re going to project data sources and you ll see our products look up data set here today they will select the data member is product can we do that if that actually add the products looks up lookup data
Minute 4
That and the table adapted to our component tray now ready to adjust the screen here stored in a go back to edit columns and a select product ID and then for the column type and said the text box column written a select the combo box column noted that some properties here to fill out will select data source is going to be our products binding source which is set up to display member is the name and a value member is the IT so this means when I selected name in the products drop down here that s been a display the product ID will be set into the order detail table tag data lookup is an excellent lot so click okay so the only final thing and then they do here is I m going to going to the view code so that when we come click save will also be saving our order details
Minute 5
And son just hit F5 to test this and you see a product orders and you can see that there is a lookup lists now for our products to when I drop when Downey can see the list of products or product table Sue and I select one what s happening is that the product ID from the product table is getting stored inside the product ID of the order detail table full
Minute 6
Names and display them here instead of showing the psyche the first Army deal is on add a new data source select database use the current connection string and this time or just a select the customer ID and a last name to call this customer lookup to this assumes we don t have a thousands of customers in our database because he is not a hard time looking through all that inside a lookup list but just this example so what really do is just delete this text box and never to make out tour toolbox and I m going to drop down a combo box and then I m going to also create a new binding source here ever got a call at
Minute 7
Customer binding source and I m going to select other data sources from our project and I m in a select the customer lookup data set which is created and the data members customer the only table in their tanks in averaging that are combo box and I can say use data bound items and we can select data source is customer binding source the display member will be the last name the value member will be customer ID and the selected value will be the orders seizing the orders binding source customer ID okay so what that means is it s going to display the last name into our drop down here only select value it will put the customer ID from the customer table into the orders table does go ahead and hit F5 on this finale can see
Minute 8
They got a drop down of customers so they can change the customer here on these orders as we scroll through them notice that they change we can make a change to this one thing I looks like it works so the last thing I want to do is I want to order the customer and products in alphabetical order in our drop down list so it s easier for our users to select the items in there so quickly I m just going to open the solution Explorer and rid of the double click on our customer lookup data set and Morgan aright click on the customer table adapter and select configure and all they do is enter an order by clause last name
Minute 9
For our products simply double click on the products lookup data set right click on product cable adapter select configure an order by name okay and now are just going to run this former time and assume we drop down you ll notice that our products are now in alphabetical order as well as our customers so I d like to thank you for your time if you like to check out the Visual Basic developer Center will be posting updates these videos there please also check out the Visual Basic team blog and my blog for more information basic and
Sunday, May 25, 2008
Video: How Do I: Create Lookup Lists?
Labels:
create,
lookup lists
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment