473,405 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Formating DateTime Cells on Datagrid

Hi there,

I have a datagrid that have a DateTime Column, that I built with this code:

DataGridTextBoxColumn ExcColumn;
ExcColumn= dgExc.TableStyles["t5_day_table"].GridColumnStyles[0] as
DataGridTextBoxColumn;

and it's been displaying the date time with this format dd/MM/yy hh:mm:ss...

The datagrid is being filled with a dataSet and I wanted it to get the date
check if it's today's date, if it's true then in spite of have dd/MM/yy
hh:mm:ss I would like the format hh:mm:ss

How can I do that, I've tried lot's of times and I didn't done it...

Thanks in Advance

Nov 17 '05 #1
1 1418
Hi,

Derive your own column style from DataGridTextBoxColumn, override the Paint
method overloads, and implement your own logic of formatting the value to a
string, then call PaintText to have the actual painting done.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
"Diogo Alves - Software Developer"
<Di*************************@discussions.microsoft .com> wrote in message
news:EC**********************************@microsof t.com...
Hi there,

I have a datagrid that have a DateTime Column, that I built with this
code:

DataGridTextBoxColumn ExcColumn;
ExcColumn= dgExc.TableStyles["t5_day_table"].GridColumnStyles[0] as
DataGridTextBoxColumn;

and it's been displaying the date time with this format dd/MM/yy
hh:mm:ss...

The datagrid is being filled with a dataSet and I wanted it to get the
date
check if it's today's date, if it's true then in spite of have dd/MM/yy
hh:mm:ss I would like the format hh:mm:ss

How can I do that, I've tried lot's of times and I didn't done it...

Thanks in Advance


Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jeff Shantz | last post by:
Hello, I'm developing a large statistics application for a call center. It often needs to calculate time spanning over months. For example, an agent's total talk time within 30 days. Since an...
2
by: sudip | last post by:
I hav a log.txt file which contains following DateTime format > Fri May 06 18:05:54 GMT+05:30 2005 . so plzz help me how to accept this format & update in my DataBase, so that my webapplication...
3
by: Andrew S. Giles | last post by:
Hello, I am importing a flat text file, and putting it into a datagrid for display on a form. Currently the users have their dates and times seperated. I have two fields, therefore in the...
1
by: JAPHET | last post by:
I am Trying to Format date in my Datagrid to SHORTDATE format with the following codes, Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As...
3
by: Tina | last post by:
I have a datagrid where I specified {0:###,###,###} at design time. However sometimes I am putting percentages in the grid instead of money and I want to change the formating to {##%}. I've...
1
by: JIM.H. | last post by:
Hello, I am using the following code to update my table through datagrid, it works fine if I have all the field as nvarchar, if I have DateTime type filed it raises exception by saying “String...
2
by: Tim::.. | last post by:
Hi I'm trying to create a pager that allows you to show records by year and month! I am getting close but would really appritiate some help! Can someone please tell me how I convert the value of...
0
by: cwbp17 | last post by:
I'm having trouble updating individual datagrid cells. Have two tables car_master (columns include Car_ID, YEAR,VEHICLE) and car_detail (columns include Car_ID,PRICE,MILEAGE,and BODY);both tables...
1
by: hodgesp | last post by:
I have a Datagrid that I'm trying to use to update a SQL table. The grid works and I get the EditCommand to work. When I make a change to a field, I get a date error. I was getting invalid cast...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.