I add columns and rows in the grid RUNTIME. Even if my column is of type DateTime and the value has both date and time, the grid displays only date, not time. I understand that there is a property to set that. I tried doing something like
grid1.DisplayLayout.Bands(0).Columns("Col1").Format = "mm/dd/yy hh:mm:ss"
- Add data(rows and Columns) to a data table (m_pDataTable) at runtime from the database
- grid1.DataSource = m_pDataTable
- Set the format for required column
Thanks in advance, Sindhu
Sindhu,
So the grid is changing the value from November to May? Do you have a MaxValue on the column that would be preventing this? I can't say that I've seen this behavior before.
-Matt
I wrote a sample program.. which has only this code.
Imports Infragistics.Win
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim m_pDataTable As DataTable Dim Col1 As DataColumn Dim Col2 As DataColumn Dim Row1 As DataRow m_pDataTable = New DataTable() Col1 = New DataColumn("Name", GetType(System.String)) m_pDataTable.Columns.Add(Col1) Col2 = New DataColumn("Date", GetType(System.DateTime)) m_pDataTable.Columns.Add(Col2) Row1 = m_pDataTable.NewRow() Row1("Name") = "Test" Row1("Date") = System.DateTime.Now m_pDataTable.Rows.Add(Row1) Me.UltraGrid1.DataSource = m_pDataTable UltraGrid1.DisplayLayout.Bands(0).Columns("Date").Format = "mm/dd/yy hh:mm:ss" ' .
UltraGrid1.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.False End SubEnd Class
I didnt write anything apart of it. This code behaves differently every time I run it.
When the date is 07/01/02008
the outputs in Date column was 31/01/08 02:32:32 once
36/01/08 02:36:35
and next time it gave 38/01/08 02:38:55. It gave different outputs everytime. I personally did not set any property. I am not sure if there is any default property or some that is set and is messing up like this??
Thanks,
Sindhu
Hey I almost got it. when i specified MM/dd/yy hh:mm:ss tt as the format it worked fine.
Thanks so much, Sindhu
The problem here is with your format string; the grid just calls ToString on the object with the string specified in the Format of the column, so that's what the grid's showing. In this particular case, you have "mm/dd", which is the same as the minutes specified later in the string (though I don't know how you got "31/01/08 02:32:32"). Try using "MM/dd/yy hh:mm:ss".