Solved

Format Date Column in Winform Datagrid

Posted on 2004-09-14
8
292 Views
Last Modified: 2010-04-23
How do you format a Date Column in a windows form.
0
Comment
Question by:XgenX
  • 4
  • 3
8 Comments
 
LVL 7

Expert Comment

by:natloz
ID: 12059516
If you go in the collection editor in the properties of the grid...there is a format property for each column that you can set...and you can use something such as

dd-MMM-yyyy to give 11-Jul-2004 for example...
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 12060996
0
 

Author Comment

by:XgenX
ID: 12146793
Ok, regarding natloz's comment, I go to the DataGrid properties and I don't see something called collection editor but I see a TableStyles property with a Collection value in the Data section of the properties (forgive me but I am still at the tard level of understanding in the .Net IDE). I assume this is what you are talking about. I go into this and there is a DataGridTableStyle2 in the members list. I go into this and go to the GridColumnStyles property collection. In there I find DataGridTextBoxColumn1 and DataGridTextBoxColumn2 Members. Each of these have dd-MMM-yyyy in the format property and are mapped to the correct field in the mapping name property. When I run it I just get 9/24/2004. There is a property in the Windows Form Designer generated code called FormatInfo that is not in the Collection Editor and that is set to Nothing. So, what am I doing wrong? BTW, I have tried various other formats such as G and mm-dd-yy-hh-mm-ss with absolutely no change. Thanks for the help.
0
 
LVL 7

Expert Comment

by:natloz
ID: 12146844
Check to see if there is a mapping name for the TableStyles collection editor...it should be mapped to the table in the dataset...
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:XgenX
ID: 12147852
Er, ok. It wasn't. So I made the single change of hand-typeing the name of the view (it's a view, by the way, not a table) and now the only thing that shows up are the two formatted fields. None of the other fields show up. Hmmm...
0
 
LVL 7

Accepted Solution

by:
natloz earned 250 total points
ID: 12147884
You have to add a GridColumnStyle for each column you wish to display in your grid...
Basically if you define a Custom Collection Style for TableStyle/Column style...then you are overriding the autogenerated style that comes with a basic grid. So...you need to add a column for each column you wish to display in your grid, I do all my grids this way because I like to format the Widths of the grid columns based on the type of info etc...plus I like to create custom headers for each column etc...does this make sense...

So because you are now defining a mapping for the custom TableStyles...it is now going to use the custom collection.
0
 
LVL 7

Expert Comment

by:natloz
ID: 12147899
I also like to add primary keys to my grid and give the Custom column a width of 0 so if I want to capture a click event in the grid I can get the primary key without the user needing to see it...
0
 

Author Comment

by:XgenX
ID: 12148402
This seems to answer everything I was misunderstanding. Thank you so much for the help!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now