Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing Textbox Values Based on a ComboBox Selection 1

Status
Not open for further replies.

Headwinds

Programmer
Feb 6, 2001
38
0
0
US
A type of Windows form that I frequently need to use has a combobox at the top and a number of textboxes and checkboxes whose values should change depending upon the selected item in the combobox. I can bind the combobox to a column in a table in a DataSet, and I would like the textbox and checkbox values to display the values of other columns in the same row.

I have the feeling that I should be able to bind the textboxes and checkboxes to the other columns in my DataSet table, and the CurrencyManager object should keep track of everything for me. However, all the CurrencyManager and BindingContext examples I have seen to demonstrate usage simply illustrate how to use the CurrencyManager.Position property to advance through the DataSet table one or more rows at a time--what I want to do is go to some specific row. Is there some relationship between the CurrencyManager.Position and the DataSet table index? Can anyone provide a code snippet?

Thanks in advance.
 
As long as you use the same table or dat view to bind to the different objects the currency manager will update you text feilds appropriatly.

Code:
'Bind the Text property of the Text box TxtBox to the second column of the data table Table

TxtBox.DataBindings.Add("Text", Table, Table.Columns(1).ColumnName)

With CmbBox
      .DataSource = Table
       'The value to display in the combo box
      .DisplayMember = Table.Columns(4).ColumnName
       'A value linked to the selected value that you can use in your program eg the Record number
      .ValueMember = Table.Columns(0).ColumnName
End With
[code/]

Now when the user changes the selection in the combo box the text feild value is altered as well.

Regards
John
 
John, if I could give you five stars I would. Can't believe how long I looked for this information, and how easy it makes things.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top