User (Old forums)MemberJuly 1, 2005 at 9:31 amPost count: 23064
I have a System.Data.DataTable that I bind to a GridControl. One of the columns contains DateTime values. The GridControl choses to show the date not as a simple dd/MM/yyyy string. It shows the start of a GridDateTimePicker instead. The cell is ReadOnly so its contents will not need to be changed. I want the GridControl to just display the date, as a formated string.
I tried setting the Cell or Column’s CellViewer (could not select GridTextBox, had to pick GridMaskedTextBox). I tried setting the Cell’s FormatProvider and FormatSpecifier properties. None of both helped.
Thanks for pointing me into the right direction,
Imported from legacy forums. Posted by panik (had 4667 views)User (Old forums)MemberJuly 1, 2005 at 10:06 amPost count: 23064
Could you show us some code that shows this behaviour?
Imported from legacy forums. Posted by Tommy (had 219 views)User (Old forums)MemberJuly 1, 2005 at 10:15 amPost count: 23064
Nothing too fancy (I left some parts out, where I subscribe events to cells or to the InsertionRow etc.):
DataViewGrid.DataSource = DataViewSet.Tables;
Xceed.Grid.Editors.GridMaskedTextBox textboxEditor = new Xceed.Grid.Editors.GridMaskedTextBox();
DataViewGrid.Columns[“Timestamp”].CellEditor = textboxEditor;
//When I make the textboxEditor a Xceed.Grid.Editors.GridTextBox,
//I can’t define the CellViewer with it
DataViewGrid.Columns[“Timestamp”].CellViewer = textboxEditor;
//This is the FormatProvider part I tried, think that could solve this problem
foreach(Cell cell in DataViewGrid.DataRowTemplate.Cells)
if(cell.FieldName == “Timestamp”)
cell.FormatProvider = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat;
cell.FormatSpecifier = “dd/MMM/yyyy HH:mm:ss”;
//Makes the Cell ReadOnly, and makes it ‘look’ ReadOnly
cell.ReadOnly = true;
cell.ForeColor = Color.DarkGray;
cell.CanBeCurrent = false;
Not sure how much this will make things clearer.
Imported from legacy forums. Posted by panik (had 524 views)User (Old forums)MemberJuly 2, 2005 at 2:26 pmPost count: 23064
First of all, I don’t think you have to set the CellEditor or CellViewer of the column: if you don’t set them, a default CellEditor and CellViewer will be used.
Second, you don’t have to loop through DataRowTemplate.Cells to find the Timestamp-cell. You can just get the cell like this: Cell cell = DataViewGrid.DataRowTemplate.Cells[“Timestamp”];
Imported from legacy forums. Posted by Tommy (had 204 views)User (Old forums)MemberJuly 4, 2005 at 3:11 amPost count: 23064
The default CellEditor and CellViewer is the whole point. I don’t want it. It renders a datetime picker. I want a simple display of the date. Not any control allowing me to change it, or that renders the date in a not standard way (a textbox, something that simple displays the date).
Imported from legacy forums. Posted by panik (had 454 views)User (Old forums)MemberJuly 4, 2005 at 8:08 amPost count: 23064
I tried it out, and I got the DateTimePicker editor, when trying to edit a cell, but when not in edit mode, the GridControl would just display the date & time, like regular text.
You could set the CellEditor & CellViewer properties of the column to <b>null</b>, to make sure there’s no editor or viewer attached to the column.
Imported from legacy forums. Posted by Tommy (had 280 views)
- You must be logged in to reply to this topic.