SIGN UP MEMBER LOGIN:    
ARTICLE

ComboBox in DataGrid in WPF

Posted by Diptimaya Patra Articles | WPF with C# February 18, 2010
This article will describe the DataGrid in Edit mode while the edit cell requires a list of data.
Reader Level:
Download Files:
 

Introduction

This article will describe the DataGrid in Edit mode while the edit cell requires a list of data. We are going to achieve that using the ComboBox.

Crating WPF Application Project

Fire up Visual Studio 2008 and Create a WPF Application and name the project as DatePickerDGWPF.

ComboBoxWPF1.gif

Here is the basic idea of our sample application; we would have sample data with one property that can be selected from a list of values displayed in ComboBox.

When the particular cell will be edit mode, we would be able to select from the list displayed in the ComboBox.

So let's have a class and have sample data.

ComboBoxWPF2.gif

Now we will add a DataGrid to the Window and design the Columns inside of it.

ComboBoxWPF3.gif

We need to set the ItemSource Property; for that I have created a Class that would generate the list and in XAML I have accessed it and assigned it. The following figures will clarify what I have done:

ComboBoxWPF4.gif

...

ComboBoxWPF5.gif

...

ComboBoxWPF6.gif

It seems we are done with the design of our DataGrid columns.

Run the application and try to edit the column "Status", you would get ComboBox control to handle the Status List.

ComboBoxWPF7.gif

And when in Edit mode:

ComboBoxWPF8.gif

After Updating:

ComboBoxWPF9.gif

Hope this article helps.

Login to add your contents and source code to this article
share this article :
post comment
 

Thanx a lot buddy for this solution... :)

Posted by gaurav verma May 17, 2012

I'm trying to do it the same but binding with ListBox or ComboBox, but I can't. I need some Template? maybe i lost in the XAML.

Posted by gio Mar 17, 2011

thanks a lot for your solutions.

Posted by Shiv Kumar Sharma Feb 21, 2011

I read through the posts on codeplex but wasn't able to figure out what the final code should be for the auto-edit. Any chance you could post it? It would be much appreciated.

Posted by Markk Harmon Feb 08, 2011

favorite it!

Posted by Jacky Lee Jan 07, 2011
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Team Foundation Server Hosting
Become a Sponsor