M
Mika M
Hi!
I have DataGrid bound to DataTable. I create DataTable "on fly" when
application start without database connection. I use datagrid only to create
simple XML-file for other purposes.
Question: DataTable contains "Time"-column, and I need to get time into it
automatically of the moment, when user adds a new row into DataGrid, but how
to do it? It can't be only something like dc.DefaultValue = DateTime.Now;
because time is not then time of the moment when DataGrid row was added by
user.
I think this must be easy, but I don't get it yet. Here's some of my code,
if needed...
DataColumn dc;
dc = new DataColumn("Time");
dc.DataType = typeof(DateTime);
dc.DefaultValue = DateTime.Now;
dt.Columns.Add(dc);
....
if(dc.ColumnName.ToString() == "Time") {
textColumn.Format = String.Format("G", textColumn.TextBox);
textColumn.ReadOnly = true;
}
I have DataGrid bound to DataTable. I create DataTable "on fly" when
application start without database connection. I use datagrid only to create
simple XML-file for other purposes.
Question: DataTable contains "Time"-column, and I need to get time into it
automatically of the moment, when user adds a new row into DataGrid, but how
to do it? It can't be only something like dc.DefaultValue = DateTime.Now;
because time is not then time of the moment when DataGrid row was added by
user.
I think this must be easy, but I don't get it yet. Here's some of my code,
if needed...
DataColumn dc;
dc = new DataColumn("Time");
dc.DataType = typeof(DateTime);
dc.DefaultValue = DateTime.Now;
dt.Columns.Add(dc);
....
if(dc.ColumnName.ToString() == "Time") {
textColumn.Format = String.Format("G", textColumn.TextBox);
textColumn.ReadOnly = true;
}