Click here to Skip to main content
12,754,607 members (33,884 online)
Click here to Skip to main content
Add your own
alternative version


44 bookmarked
Posted 1 Jan 2003

Custom Data Grid with Field Chooser functionality

, 1 Jan 2003
Rate this:
Please Sign up or sign in to vote.
A datagrid control with field chooser context menu

Custom Data Grid with all fields from product table

Figure - Custom Data Grid with all fields from product table

 Field chooser dialog

Figure - Field chooser dialog

Custom Data Grid without ProductId filed

Figure - Custom Data Grid without ProductId field

Product Name back Color changed

Figure - Product Name back Color changed

<!------------------------------- STEP 3 ---------------------------><!-- Add the article text. Please use simple formatting (


etc) -->


This custom data grid allows the user to select the columns to be displayed, change the columns order as needed at runtime. This grid will display a Field Chooser context menu when you click on the column header row which when selected will display a Field Chooser dialog box where the user can choose, exclude and re-arrange the grid columns. User may also wish to change the back color of a column.


I had to develop a custom data grid for a project where the user should have an option to choose the columns to be displayed and change the order of the columns as needed (just like outlook, although it was done using a list view). So, I thought it would be a good idea to extend the basic data grid and add some functionality to it.

I am sure that there would be a better way to implement this feature and would like any comments or suggestions on this.

Using the code

In this example, the CustomGrid displays the Product Table contents from the Northwind database. I used DataTable as a DataSource to the grid. You may wish to use any other source such as DataSet or DataView but you need to make changes to the grid control code.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
Australia Australia
No Biography provided

You may also be interested in...


Comments and Discussions

SuggestionWPF Column Chooser Pin
Member 432946923-Dec-11 4:50
memberMember 432946923-Dec-11 4:50 
Found good column choosser
Column Chooser

Project Description
WPF Datagrid currently dosent have column chooser.
In this column chooser you can even drag and drop the column to move its position on the grid.
You can even update header value on the fly just by double clicking on it.

Features include:

Column chooser with checkbox to make column visible and invisible.
Select All checkbox is added.
You can drag and drop a row from column chooser to move column in the main grid.
By double clicking on any cell of column chooser you can edit the column header values.
Column Chooser tool is deveoped in C# Visual Studio 2010 . You can even download the application via click once installation method.
QuestionDatagrid-with-integrated-field-chooser Pin
danies81-Aug-11 4:15
memberdanies81-Aug-11 4:15 
Generaldata grid functioning Pin
deepakkp26-Sep-06 21:54
memberdeepakkp26-Sep-06 21:54 
Questionhelp me... Pin
rnivuu28-Aug-06 9:06
memberrnivuu28-Aug-06 9:06 
QuestionHow to create a customize datagrie Pin
Murtala7-Dec-05 8:23
memberMurtala7-Dec-05 8:23 
Generaluse my own tablesytle Pin
Mesut Koşucu8-Sep-05 4:56
memberMesut Koşucu8-Sep-05 4:56 
aqui_i11-May-05 18:17
memberaqui_i11-May-05 18:17 
QuestionHow to change value Pin
mtnhan28-Jan-05 18:31
membermtnhan28-Jan-05 18:31 
QuestionHow can reach a column in datagrid Pin
mamreza26-Feb-04 20:25
membermamreza26-Feb-04 20:25 
Generalpoor code design and principles Pin
alby gain9-Oct-03 17:18
memberalby gain9-Oct-03 17:18 
GeneralRe: poor code design and principles Pin
PRamos7-Feb-06 0:28
memberPRamos7-Feb-06 0:28 
Generaljust what I needed... Pin
ximox10-Jun-03 5:10
memberximox10-Jun-03 5:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170217.1 | Last Updated 2 Jan 2003
Article Copyright 2003 by GKris
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid