Home Forums WinForms controls Xceed Grid for WinForms Prevent GridCell to show DateTime with GridDateTimePicker Reply To: Prevent GridCell to show DateTime with GridDateTimePicker

User (Old forums)
Post 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[0];

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)