WPF ComboBox SelectionChanged 001

WPF ComboBox SelectionChanged – SelectedItem Method

WPF ComboBox SelectionChanged method helps us get the object selected by the users on the WPF Form/Page. Method for WPF Combox SelectionChanged : Object[] data = ((DataRowView)e.AddedItems[0]).Row.ItemArray; txtBSelectedDay.Text = “You Selected : ” + data[1].ToString() + ” and its Id : ” + data[0].ToString(); We get data in form of Array. We can then select […]

Read More

WPF ComboBox SelectionChanged 001

WPF Bind ComboBox using MS SQL database

WPF Bind ComboBox using SQL database. WPF Fill Combo Box using MS SQL Database. Code : String connectionString = “Data Source=192.168.0.192;Initial Catalog=ParallelCodes;User ID=sa;Password=789”; SqlConnection con = new SqlConnection(connectionString); SqlCommand cmd = new SqlCommand(“select * from Producttbl”, con); con.Open(); SqlDataAdapter adapter = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); adapter.Fill(dt); cbbDays.ItemsSource = dt.DefaultView; cbbDays.DisplayMemberPath = “ProName”; […]

Read More