---
title: "Combobox at runtime in c# wpf."  
description: "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 d"  
author: "Anonymous User"  
published: 2011-04-28  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/148/combobox-at-runtime-in-c-sharp-wpf  
category: "wpf"  
tags: ["wpf"]  
reading_time: 1 minute  

---

# Combobox at runtime in c# wpf.

In this [blog](https://www.mindstick.com/articles/12705/myths-and-misconception-about-blog) I am going to tell you that how to [add](https://www.mindstick.com/forum/448/how-to-add-advertisement-functionalities-in-asp-dot-net-page) [elements](https://www.mindstick.com/forum/1440/wpf-button-with-multiple-text-elements) in combo box at [runtime](https://www.mindstick.com/articles/52/creating-timer-at-runtime-in-c-sharp-dot-net) using [c# code](https://www.mindstick.com/articles/334681/5-tips-to-writing-clean-c-sharp-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.
```

##### Finally execute your program to test your code.

---

Original Source: https://www.mindstick.com/blog/148/combobox-at-runtime-in-c-sharp-wpf

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
