Posted 26 July 2018, 9:30 am EST
How can I force DateTime column to edit by simple TextBox and not by DatePicker ??
Forums Home / ComponentOne / WinForms Edition
Posted by: moshek on 26 July 2018, 9:30 am EST
Posted 26 July 2018, 9:30 am EST
How can I force DateTime column to edit by simple TextBox and not by DatePicker ??
Posted 27 July 2018, 2:27 am EST
Hi,
To force the DateTime column to be edited by simple TextBox, you can capture the “StartEdit” event of the grid and check whether the data type of the column is DateTime. If yes, set the “C1FlexGrid.Editor” property to the TextBox control.
if (_grid[e.Row, e.Col].GetType() == typeof(DateTime))
{
_grid.Editor = _textBox;
}
For reference please see the attached sample. Try editing the cells of the columns with names “BirthDate” and “HireDate”.
Please let us know if you need any other help.
Thanks.
DateTimeTextBox.zip
Posted 29 July 2018, 5:55 am EST
Very ugly.
I need that HireDate will work like Address.20180729_124433.zip
Posted 30 July 2018, 5:56 am EST
Hi Moshe!
In order to deal with DateTime type values in the grid cells, without showing DateTimePicker, you can take advantage of EditMask and Format properties of C1FlexGrid column.
//For HireDate column :
_grid.Cols[7].DataType = typeof(object);
_grid.Cols[7].Format = "d";
_grid.Cols[7].EditMask = "00-00-0000";
Regards,
Meenakshi