Linking a WPF List and Displaying its Value in a TextBox

Hi friends, I want to display data from the database in combobox, the DB table has id, investPlan, amount. Now I want to show investGln colover in combobox, and when the user selects any plan, then the corresponding amount is displayed in the textBox control. I can display the lines of 'invetsPlan' in a comboBox, but I don’t know how to do anything to relax. HELP ME !!

XAML part

<ComboBox Height="23" Margin="70,72,88,0" Name="comboBox1" VerticalAlignment="Top" DropDownClosed="comboBox1_DropDownClosed" 
              ItemsSource="{Binding}" IsSynchronizedWithCurrentItem="True" SelectedValue="{Binding Path=id}" DisplayMemberPath="fullName" SelectedValuePath="id"/>

Code piece by piece

private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        DataSet1TableAdapters.membersTableAdapter ta = new ComboBoxDB.DataSet1TableAdapters.membersTableAdapter();
        comboBox1.ItemsSource = ta.GetData();
    }
+5
source share
2 answers

You are almost there!

<TextBox Text="{Binding ElementName=comboBox1, Path=SelectedItem.amount}" />

There you go :)

+6
source

Combobox has an event to trigger an item change. You can use this event .SelectionChanged

0

All Articles