Blog
    C#
    ADO.Net
    .NET
    ASP.Net & Web Forms
    Custom Controls
    Web Development
    Exception Handling
    XML
    Database
    Security in .Net
    Testing
    Web Services
    Windows Services
    Windows Controls
    WCF
    AJAX
    WPF
    XAML
    Reporting
    Setup
    VB.Net
    LINQ
    JQuery
    SilverLight
    JavaScript
    HTML5
    Crystal Report
    Cloud Computing
    Share Point
    Visual C++
    MVC
    Android
    PHP
    Java
    HTML
    WordPress
    Joomla
    Products
    Drupal
    Windows Phone
    JSON
    LightSwitch
    iPhone/iPad
    Ruby on Rails
    IIS 7
    Windows 8
    CSS/CSS3
    Excel
    MS Access
    Shortcut Keys
    Visual SourceSafe
    Team Foundation Server
    APIs
Follow Us
Follow _MindStick_ on Twitter View MindStick Software's LinkedIn profile View MindStick Software's Facebook profile
Top Contributor
Advertisement
Advertise with Us
Mindstick
Article Article  Forum Forum  Blog Blog  Quiz Quiz  Beginner Beginner  Careers Careers  Contact Contact  Login Login  
Home | Product | Services | About Us | Interview | DeveloperSection | Submit an Article | Submit Blog
Report Abuse Form
Reason:    
 

Home >> WPF >> Combobox at runtime in c# wpf.
Combobox at runtime in c# wpf.

In this blog I will tell you that how to add combobox in wpf at runtime.
Views: 1940     Comments: 0
by Awadhendra Tiwari on 4/28/2011

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.

Finally execute your program to test your code.

Title :  
Comment :
Text ColorBackground Color
BoldItalicUnderline
LeftCenterRightJustify
Ordered ListBulleted List
IndentOutdent
Horizontal Rule
SubscriptSuperscript
HyperlinkImage
Design ModeDesign
View HtmlHtml
       
 
Report Abuse Form
Reason:    
 
Latest ArticleRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Latest Blogs by Awadhendra TiwariRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Top Viewed ArticlesRSS Feed
    
    
    
    
    
    
    
    
    
    
Top Viewed BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
Latest Interview QuestionsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Total Online Users: 3957
  
Copyright © 2013MindStick. All Rights Reserved.