You must Sign In to post a response.
  • Category: WPF

    I have a query in WPF C# combobox.

    I have a combobox with "Application", "Documentation1", "Documentation2", "Bootloader" and check box "a","b" and "c".

    When form load from combo box enable "Application" and disable another all items.

    When user click on "b" check box then disable all except "Document1" and "Document2".

    when again user click "c" check box then disable all except "Bootloader"
  • #768710
    Here is the example code snippet for bind data dynamically from the database and get the ComboBox
     using System.Data;
    using System.Data.SqlClient;
    namespace WpfComboBox
    {
    public partial class MainWindow : Window
    {
    public MainWindow()
    {
    InitializeComponent();
    BindComboBox(ComboBoxStudent);
    }
    public void BindComboBox(ComboBox comboBoxName)
    {
    SqlConnection conn = new SqlConnection("Connection Your string");
    SqlDataAdapter da = new SqlDataAdapter("Select StudentId,StudentName FROM tblStudents", conn);
    DataSet ds = new DataSet();
    da.Fill(ds, "tblStudents");
    comboBoxName.ItemsSource = ds.Tables[0].DefaultView;
    comboBoxName.DisplayMemberPath = ds.Tables[0].Columns["StudentName"].ToString();
    comboBoxName.SelectedValuePath = ds.Tables[0].Columns["StudentId"].ToString();
    }
    }


  • Sign In to post your comments