In this blog I am going to tell you that how to add elements in combo box at runtime using c# code.
Follow these steps to implement this task.
Write down following xaml code :
<Grid Loaded="Grid_Loaded" x:Name="grid1">
</Grid>
At the load events of grid control write down following code to add
combo box.
ComboBox cmb = new ComboBox(); //Create an object of combo box.
cmb.Width = 200; //set width of combo box.
cmb.Height = 30; //set height of combo box.
cmb.Items.Add("---Select Fruits---"); //add items in combo box.
cmb.SelectedIndex = 0;
cmb.Items.Add("Apple");
cmb.Items.Add("Mango");
cmb.Items.Add("Banana");
cmb.Items.Add("Graps");
grid1.Children.Add(cmb); //Add combo box in grid control.
Anonymous User
25-Mar-2019Thanks for sharing.
Sushant Mishra
19-Jul-2017It is great to associate with such a blog.