gridView DateTime Column format

2 posts, 1 answers
  1. acasegra
    acasegra avatar
    4 posts
    Member since:
    Apr 2011

    Posted 25 May 2012 Link to this post

    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.
  2. Answer
    Ivan Petrov
    Ivan Petrov avatar
    718 posts

    Posted 30 May 2012 Link to this post

    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.

    Ivan Petrov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top