Posted 11 November 2019, 11:16 pm EST - Updated 3 October 2022, 3:31 pm EST
I have to write a software, where the user can define formats for user input fields. In the database this fields are stored as strings because I only know the datatype of the fields at runtime. Therfore I’m trying to set the datatype and the format of a column in the grid at runtime like this:
c1FlexGrid1.Cols["Date1"].DataType = typeof(DateTime);
c1FlexGrid1.Cols["Date1"].Format = "D";
The grid is in bound mode. But the format only works if the bound field is of type DateTime and doesn’t work if the bound field is of type string:
public DateTime Date1 { get; set; }
public string Date2 { get; set; }
How can I tell the grid to format the bound string field also in the correct date format?
Attached you can find a screenshot of the two fields (DateTime and string) in the grid and a small test project written in C#.
Thanks for you help
Markus