Solved

Format Date Column in Winform Datagrid

Posted on 2004-09-14
8
309 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 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need a starter for ETL protocol? 4 57
Footer for each row on Gridview 2 21
VB.Net WebRequest Code from JSON curl 9 13
VB.NET 2008 Publish Error 2 27
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
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 Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

773 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