This is a migrated thread and some comments may be shown as answers.

gridView DateTime Column format

1 Answer 215 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
acasegra
Top achievements
Rank 1
acasegra asked on 25 May 2012, 05:02 PM
hi, I have a radgridview
with columns defined like this
gridViewDateTimeColumn1.EditorType = Telerik.WinControls.UI.GridViewDateTimeEditorType.TimePicker;
gridViewDateTimeColumn1.EnableExpressionEditor = true;
gridViewDateTimeColumn1.FieldName = "Me_Dia1";
gridViewDateTimeColumn1.Format = System.Windows.Forms.DateTimePickerFormat.Time;
gridViewDateTimeColumn1.FormatString = "{0:t}";
gridViewDateTimeColumn1.HeaderText = "Me_Lun";
gridViewDateTimeColumn1.IsAutoGenerated = true;
gridViewDateTimeColumn1.Name = "Me_Dia1";
gridViewDateTimeColumn1.Width = 65;
but i the keyboard inputs dont work well, and in the field and popup window show "{0:}"
I need work only with time in this columns.
thanks,
Alfonso

1 Answer, 1 is accepted

Sort by
0
Accepted
Ivan Petrov
Telerik team
answered on 30 May 2012, 11:58 AM
Hi Alfonso,

Thank you for writing.

You can change the format of the editor in the CellEditorInitialized event. Here is a code snippet which demonstrates this:
this.radGridView1.CellEditorInitialized += new GridViewCellEventHandler(radGridView1_CellEditorInitialized);
 
private void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
  if (e.ActiveEditor is GridTimePickerEditor)
  {
    GridTimePickerEditor editor = (GridTimePickerEditor)e.ActiveEditor;
    RadTimePickerElement editorElement = (RadTimePickerElement)editor.EditorElement;
    editorElement.Format = "t";
  }
}

I hope this will be useful for you. Should you have further questions, I would be glad to help.

Greetings,
Ivan Petrov
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
acasegra
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Share this question
or