|
-
Dec 16th, 2003, 06:30 AM
#1
Thread Starter
Fanatic Member
Time in datagrid
Hi all ive got a datagrid which is returning 3 column on a rs
ID, Time, Task
time is being shown as 01/01/1900 i guess this is because i am only storing a time and no date (Idont want to store a date) how can i apply the mm/hh/ss format to this in the datagrid I am running a function to format the DG so that may help
VB Code:
Private Sub AddCustomDataTableStyles(ByVal dstData As DataSet)
'Clear the table styles for the datagrid
DataGrid1.TableStyles.Clear()
'Declare local variables
Dim tsTableStyle As New DataGridTableStyle
Dim tcTextCol As DataGridTextBoxColumn
Dim intCounter As Integer
'Map the table style to the table in the dataset
tsTableStyle.MappingName = dstData.Tables(0).TableName()
'Add textbox column style for each column in the dataset
For intCounter = 0 To dstData.Tables(0).Columns.Count() - 1
'Reinstantiate the text box column and set mappings and attributes
tcTextCol = New DataGridTextBoxColumn
tcTextCol.MappingName = dstData.Tables(0).Columns.Item(intCounter).ColumnName
tcTextCol.HeaderText = dstData.Tables(0).Columns.Item(intCounter).ColumnName
'Set column size based on name
Select Case tcTextCol.MappingName()
Case "Task"
tcTextCol.Width() = 275
Case "Time"
tcTextCol.Width() = 51
Case "ID"
tcTextCol.Width() = 18
Case Else
tcTextCol.Width() = 50
End Select
'Add the column to the table style
tsTableStyle.GridColumnStyles.Add(tcTextCol)
Next
'Add the table styles to the datagrid
DataGrid1.TableStyles.Add(tsTableStyle)
End Sub
I am curretly building a defect management system for software and web developers,
If you wana try it out (beta test) and keep it for free just send me a message
-
Dec 16th, 2003, 08:20 AM
#2
Addicted Member
'Set column size based on name
Select Case tcTextCol.MappingName()
Case "Task"
tcTextCol.Width() = 275
Case "Time"
tcTextCol.Width() = 51
Case "ID"
tcTextCol.Width() = 18
Case Else
tcTextCol.Width() = 50
End Select
You can add: in section : Case "Time"
tcTextCol.Format = "MM/dd/yyyy"
or any format you want
regard j
-
Dec 17th, 2003, 08:59 AM
#3
Thread Starter
Fanatic Member
thats cool thanks mate
Do u know if theres a way of changing the value of the column ?
i mean some records return 00:01 because there an all day event i would like to If possible on records with 00:01 to change to "All Day"
I am curretly building a defect management system for software and web developers,
If you wana try it out (beta test) and keep it for free just send me a message
-
Dec 18th, 2003, 08:54 AM
#4
Hyperactive Member
ah the only way you are going to do thatt, is to load the intial value as an unformatted string and then run through the dataset and set the format accordingly to whether a time format or the 'All Day' text. Table styles wont help you there and even that won't work because the underlying value is a date/time stamp field. Perhpas your best bet is to use an unbound field which gets populated on the basis of the value of the underlying dataset.
Sorry can't think of an easy answer, maybe someonelse has one
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|