Click to See Complete Forum and Search --> : Change Date format in List view
dr223
August 5th, 2009, 04:35 AM
Hallo,
I have a date format on my list view which is read from sql server , i.e., the date format is expressed as for example 12/08/2009 12:00:00
I dont want to show the 12:00:00 at the front end level. At runtime the user will only see for example 12/08/2009 ONLY. How can I achieve that with the details shown below. Just need to format the SubItems(2) as it contains the date...
LvwColProc.Items(0).SubItems(2).Text
Thanks in advance.
Regards
HanneSThEGreaT
August 5th, 2009, 08:07 AM
Have you tried using the Format function ¿
dr223
August 5th, 2009, 10:33 AM
nop
I have the followung sub where I need to insert the format function but I dont know the syntax,
Private Sub PopulateListViewColProc()
Me.LvwColProc.Items.Clear()
For Each com As ColProc In mColProc
Dim item As New ListViewItem()
PopulateListViewItemColproc(item, com)
Me.LvwColProc.Items.Add(item)
TxtCurrProcStage.Text = LvwColProc.Items(0).SubItems(1).Text
If (LvwColProc.Items(0).SubItems(2).Text = "01/01/1900") Or (LvwColProc.Items(0).SubItems(2).Text = "01/01/2025") Then
LvwColProc.Items(0).SubItems(2).Text = ""
End If
Next
End Sub
HanneSThEGreaT
August 5th, 2009, 10:42 AM
Here's a nice example :
http://msdn.microsoft.com/en-us/library/59bz1f0h(VS.71).aspx
:)
dr223
August 5th, 2009, 10:59 AM
Thanks, tried the following code it gives an error;
Unable to cast object of type 'ListViewSubItem' to type 'System.IConvertible'.
How can I adjust the code...
Private Sub PopulateListViewColProc()
Me.LvwColProc.Items.Clear()
For Each com As ColProc In mColProc
Dim item As New ListViewItem()
PopulateListViewItemColproc(item, com)
Me.LvwColProc.Items.Add(item)
TxtCurrProcStage.Text = LvwColProc.Items(0).SubItems(1).Text
If (LvwColProc.Items(0).SubItems(2).Text = "01/01/1900") Or (LvwColProc.Items(0).SubItems(2).Text = "01/01/2025") Then
LvwColProc.Items(0).SubItems(2).Text = ""
End If
Dim MyDateTime As Date = #1/27/2001 5:04:23 AM#
Dim MyStr As String
'Also returns current system date in the system-defined long date
' format, using the single letter code for the format.
MyStr = Format(LvwColProc.Items(0).SubItems(2), "d-mm-yyyy")
Next
End Sub
HanneSThEGreaT
August 5th, 2009, 11:08 AM
Try this :
MyStr = Format(LvwColProc.Items(0).SubItems(2).Text, "d-mm-yyyy")
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.