Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Format Date Column in Winform Datagrid

Posted on 2004-09-14
8
Medium Priority
?
345 Views
Last Modified: 2010-04-23
How do you format a Date Column in a windows form.
0
Comment
Question by:XgenX
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 70

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 

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 1000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

670 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