473,946 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataTablet, Datagrid, and DateTime

Hi all,

I've got a DataTable that has a datetime column that is bound to a datagrid.
The Datetime Column holds both Date *and* time, but my Datagrid only shows
the date. How would I go about getting it to display both Date *and* time?

regards,

Marco
Nov 15 '05 #1
2 3789
Hi Marco,

1. Configure the grid with a programmaticall y created DataGridTableSt yle
pre-populated with DataGridColumnS tyle instances (see the
"DataGridTableS tyle Class" topic in MSDN for detailed information).
2. Set the Format property on the corresponding DataGridColumnS tyle to the
appropriate value (most likely "f", "F", "g" or "G"). See the "Standard
DateTime Format Strings" topic in MSDN for more information.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Marco Martin" <ma**********@s ympatico.ca.ant ispam> wrote in message
news:lj******** **********@news 20.bellglobal.c om...
Hi all,

I've got a DataTable that has a datetime column that is bound to a datagrid. The Datetime Column holds both Date *and* time, but my Datagrid only shows
the date. How would I go about getting it to display both Date *and* time?
regards,

Marco


Nov 15 '05 #2
Thanks,

Much appreciated.

Marco
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.c om> wrote
in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Hi Marco,

1. Configure the grid with a programmaticall y created DataGridTableSt yle
pre-populated with DataGridColumnS tyle instances (see the
"DataGridTableS tyle Class" topic in MSDN for detailed information).
2. Set the Format property on the corresponding DataGridColumnS tyle to the
appropriate value (most likely "f", "F", "g" or "G"). See the "Standard
DateTime Format Strings" topic in MSDN for more information.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Marco Martin" <ma**********@s ympatico.ca.ant ispam> wrote in message
news:lj******** **********@news 20.bellglobal.c om...
Hi all,

I've got a DataTable that has a datetime column that is bound to a

datagrid.
The Datetime Column holds both Date *and* time, but my Datagrid only shows the date. How would I go about getting it to display both Date *and*

time?

regards,

Marco

Nov 15 '05 #3

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

Similar topics

8
2351
by: Gilles T. | last post by:
How I can get element ID in the edit mode of datagrid control? If I not in the edit mode, there are no problem. <asp:TemplateColumn ItemStyle-CssClass="grid_column_width_3" ItemStyle-HorizontalAlign="center" ItemStyle-VerticalAlign="top"> <ItemTemplate><%# CType(Container.DataItem("DateStatut"),DateTime).ToString("yyyy-MM-dd") %></ItemTemplate> <EditItemTemplate> <asp:TextBox width="80" CssClass="edit_item" id="txtDateStatut"
2
1485
by: Marcos Rodríguez | last post by:
Hi all I have an Access Data Base containing a table which have a DateTime Field. I am creating a Windows App and I am using a DataGrid object to show data from the table using a DataSet object. My problem is that the column showing the DateTime field shows the data with the format dd/MM/yyyy but I want to show the format dd/MM/yyyy HH/mm The Field on the DataBase is defined as DateTime with the format dd/MM/yyyy HH:mm. Also I have created the...
2
7812
by: A Programmer | last post by:
I can't believe I have never run into this before but, I have an object that has a property of type DateTime. A collection of these objects are used to populate my DataGrid. In DateTime format they display the date AND the time, I don't need nor want the time just the date. If I format at any point to a ShortDate I have to convert the type to a string which when applied to the grid interferes with sorting. Is there any way to keep the...
1
2600
by: Soul | last post by:
*** I am not sure this question belong to *.languages.csharp or *.framework.windowsdorms.databinding, so I post to both *** Hi, Currently I have a DataGrid which bind to a DataSet. One of the column in the DataSet table consist of DateTime value. I also have two DateTimePicker (startDate and endDate) on my Windows form.
3
1678
by: Jim H | last post by:
I have a DataGrid where the DataSource is a DataTable that has a DateTime column. Right now it only shows the Date, I want the date and time down to the seconds or better. How do I set the DataGrid to display the DateTime value in the format I want. DateTime.ToString("MM/dd/yyy hh:mm:ss:fff") Thanks, jim
3
4246
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 datatable feeding the datagrid control. Both are of the DateTime Type. How do I get the time field to display only the Time, and not the date, which is apparently the default.
3
1966
by: Paul Say | last post by:
I have a class called Job, that has several properties JobID,Description & StartDate. The StartDate is Property is defined as follows public Class Job private _StartDate as DateTime public property StartDate() as DateTime get return _StartDate
0
1220
by: Chia Lee Lee | last post by:
Hi, I try to bind records into datagrid based on certain condition.The condition is when the Rdate in database column is larger than today date will be display on datagrid. my problem is , the records display is not fullil the condition i set. as long as the day value(dd) (RDate) is larger than today day value(dd), it will display on datagrid.It ingore the Month and Year.It seen look like it compare as string instead of dateTime. The...
1
3840
mafaisal
by: mafaisal | last post by:
Hello Experts I am Using vb.net 2005 Hw To Put DateTime Picker in Datagrid view I have to sea Datetime Picker in Specified Cilomn of Datagrid I try This But The Location Hw To Change to the column location or In DatagridView any Datetime Picker like DataGridViewComboBoxColumn,DataGridViewCheckBoxColumn etc..?
0
10151
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9977
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11150
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11333
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9882
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8245
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7412
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6106
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6325
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.