Add items to comboBox in WPF

前端 未结 7 1877
谎友^
谎友^ 2021-02-03 21:38

When I have added a comboBox to the WPF window, how do I add items to the comboBox? Int the XAML code for the design or in NameOfWindow.xaml.cs file?

7条回答
  •  情深已故
    2021-02-03 22:09

    With OleDBConnection -> connect to Oracle

    OleDbConnection con = new OleDbConnection();
                con.ConnectionString = "Provider=MSDAORA;Data Source=oracle;Persist Security Info=True;User ID=system;Password=**********;Unicode=True";
    
                OleDbCommand comd1 = new OleDbCommand("select name from table", con);
                OleDbDataReader DR = comd1.ExecuteReader();
                while (DR.Read())
                {
                    comboBox_delete.Items.Add(DR[0]);
                }
                con.Close();
    

    That's all :)

提交回复
热议问题