473,811 Members | 3,579 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting time format in datagrid

I'm trying to format datetime column in datagrid to a time
format rather than date. I'm using code:

Dim myGridTextBoxCo lumn As DataGridTextBox Column = New
DataGridTextBox Column()

myGridTextBoxCo lumn = CType(datagrid. TableStyles
(0).GridColumnS tyles("StartDat e"), DataGridTextBox Column)

myGridTextBoxCo lumn.Format="hh :mm:ss tt"

However, that last line always give error"Object reference
not set to an instance of an object."

What am I doing wrong?

Thank you

Sebastian

Nov 20 '05 #1
2 6486
Hi,

Dim cm As CurrencyManager = CType(Me.Bindin gContext(dvClie nt),
CurrencyManager )

Dim pd As PropertyDescrip tor = cm.GetItemPrope rties()("Appoin tDate")

Dim colDate As New DataGridTextBox Column(pd, "t")

With colDate

..MappingName = "ApointDate "

..HeaderText = "Date"

..Width = 100

End With

Ken

---------------------

"Sebastian Santacroce" <ss*********@il ogic.com> wrote in message
news:00******** *************** *****@phx.gbl.. .
I'm trying to format datetime column in datagrid to a time
format rather than date. I'm using code:

Dim myGridTextBoxCo lumn As DataGridTextBox Column = New
DataGridTextBox Column()

myGridTextBoxCo lumn = CType(datagrid. TableStyles
(0).GridColumnS tyles("StartDat e"), DataGridTextBox Column)

myGridTextBoxCo lumn.Format="hh :mm:ss tt"

However, that last line always give error"Object reference
not set to an instance of an object."

What am I doing wrong?

Thank you

Sebastian

Nov 20 '05 #2
I tryed to apply this to what I have but it did not do
anything. Heres the code I used in reference to my first
email trying to merge with your code.
'ds is the dataSet
'StartTime is the field column name I want as time not
date.

Please clarify were I went wrong.

Thank you.
Dim cm As CurrencyManager = CType(Me.Bindin gContext(ds),
CurrencyManager )

Dim pd As System.Componen tModel.Property Descriptor
= cm.GetItemPrope rties()("StartT ime")

Dim colDate As New DataGridTextBox Column(pd, "t")

With colDate

.MappingName = "StartTime"

.HeaderText = "StartTime"

.Width = 100

End With
-----Original Message-----
Hi,

Dim cm As CurrencyManager = CType(Me.Bindin gContext (dvClient),CurrencyManage r)

Dim pd As PropertyDescrip tor = cm.GetItemPrope rties() ("AppointDat e")
Dim colDate As New DataGridTextBox Column(pd, "t")

With colDate

..MappingNam e = "ApointDate "

..HeaderText = "Date"

..Width = 100

End With

Ken

---------------------

"Sebastian Santacroce" <ss*********@il ogic.com> wrote in messagenews:00******* *************** ******@phx.gbl. ..
I'm trying to format datetime column in datagrid to a time format rather than date. I'm using code:

Dim myGridTextBoxCo lumn As DataGridTextBox Column = New
DataGridTextBox Column()

myGridTextBoxCo lumn = CType(datagrid. TableStyles
(0).GridColumnS tyles("StartDat e"), DataGridTextBox Column)
myGridTextBoxCo lumn.Format="hh :mm:ss tt"

However, that last line always give error"Object reference not set to an instance of an object."

What am I doing wrong?

Thank you

Sebastian

.

Nov 20 '05 #3

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

Similar topics

4
2698
by: karunakar | last post by:
Hi All I was poplating Datagrid Datagrid has one of the column showing datetime field format iam showing DATE here not Necessary to populate the Time Frame Even my datebase column also does'nt have any time frame Query is shoing only dates; But ASP.NET dategrid showing Time frame also, How can remove the time frame in datagrid
7
1833
by: Mike L | last post by:
This is for a Win form. SP sends back the PostMark date to my datagrid, shows proper date in datagrid. When user clicks on datagrid, the code sends the current row to text box. The text box shows the date and 12:00:00 AM. How do I get rid of the time? My code below. int rowNum = dgDealerInfo.CurrentCell.RowNumber;
1
2316
by: J.B | last post by:
I have a datagrid that will display different datasets, (it runs different sprocs based on a value in the querystring) but it will always return 6 columns. The 5th and 6th columns are always Date and Currency format, all others are strings. I'd like to build one datagrid to handle this datagrid dynamically. I have it working now, all except the formatting of the 5th (Date) and 6th (Currency) columns. Since the headers for those...
6
3847
by: Hutty | last post by:
I've looked around and have yet to find anything that would answer my question regarding formating a column in a datagrid. My grid looks like this as far as data" AMHQCON|51300.01|-3147 The first two columns are pretty much text column, but subsequent columns 1-12 are numerical. I'm trying to get the thousand separator to work. Any ideas?
3
11740
by: Reney | last post by:
I am using Access Database in my program. The column in the table that I am going to use has date/time value with Medium Time selected. (HH:mm). The program is recording a clock in time to this field, which is the time when the entry is made. If you check the database, it shows the correct time in the correct format. But when you are calling it with a dataset and showing with a datagrid, it doesn't show the time value but it always shows...
2
1962
by: TerryW | last post by:
I am using a system.windows.forms.datagrid and i set it's data source to a system.data.datatable which has a column that's dataType is system.dateTime. When I try to enter minutes and seconds into the grid it removes that time data and leaves only the date. The time information is still there though. How can I make the time visible? TIA TerryW
3
9929
by: | last post by:
I wrote a class in VB.NET to export the contents of a datagrid to Excel. It works perfectly on my machine, but it fails on my customers' PCs that have identical versions of Win XP (SP1) and Excel (SP1) installed. The error is: System.Runtime.InteropServices.COMException(0x800A03EC): Exception from HRESULT: 0x800A03EC. at Microsoft.Office.Interop.Excel._Worksheet.Paste(Object Destination, Object Link) at...
4
1232
by: Dan Aldean | last post by:
Hello, I have some fields in the dataset that bear date and time values. When I bind the datagrid the time part of the fields don't show. Is it possible to format the datagrid columns so that they show the whole thing? Thanks
1
1355
by: =?Utf-8?B?TU4=?= | last post by:
I have a simple app that lists some times from a SQL database dt.Columns.Add(New DataColumn("Start Time", GetType(String))) Dim cn As New SqlConnection(sqlConnString) cn.Open() sqlStatement = "Select EndTime from Mytable Dim cmd As New SqlCommand(sqlStatement, cn) Dim dr As SqlDataReader = cmd.ExecuteReader Do While dr.Read() MyDataRow = dt.NewRow()
0
9731
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
9605
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
10651
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10405
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
9208
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
7671
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
5697
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4342
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3871
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.