Click here to Skip to main content
Click here to Skip to main content

Custom Data Grid with Field Chooser functionality

By , 1 Jan 2003
 

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

Introduction

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.

Background

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.

License

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

GKris
Web Developer
Australia Australia
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
SuggestionWPF Column ChoosermemberMember 432946923 Dec '11 - 3:50 
QuestionDatagrid-with-integrated-field-choosermemberdanies81 Aug '11 - 3:15 
Generaldata grid functioningmemberdeepakkp26 Sep '06 - 20:54 
Questionhelp me...memberrnivuu28 Aug '06 - 8:06 
QuestionHow to create a customize datagriememberMurtala7 Dec '05 - 7:23 
Generaluse my own tablesytlememberMesut Koşucu8 Sep '05 - 3:56 
GeneralDATA GRID QUESTIONmemberaqui_i11 May '05 - 17:17 
QuestionHow to change valuemembermtnhan28 Jan '05 - 17:31 
QuestionHow can reach a column in datagridmembermamreza26 Feb '04 - 19:25 
Generalpoor code design and principlesmemberalby gain9 Oct '03 - 16:18 
GeneralRe: poor code design and principlesmemberPRamos6 Feb '06 - 23:28 
Generaljust what I needed...memberximox10 Jun '03 - 4:10 

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

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