O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Bind a Field to a List Control, and Restrict It to the Values from Another Table

Problem

You want to fill a list control with allowed values from one table and use it to edit a field in another table.

Solution

Fill the list control with allowed values by setting the DataSource, DisplayMember, and ValueMember properties. Then bind the list control’s SelectedValue to the field you want to edit using the DataBindings collection.

Discussion

List controls can play two roles in Windows data binding:

  • Record navigation. In this case, you set the DataSource, DisplayMember, and ValueMember properties. For example, if you bind the list control in this way to the ProductName column in a Products table, the list will be filled with all the product names in the table. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required