DataEditFormatString in GridView

3 posts, 0 answers
  1. Emmanuel Dugas-Gallant
    Emmanuel Dugas-Gallant avatar
    8 posts
    Member since:
    Mar 2010

    Posted 06 Jul 2010 Link to this post

    Hi,

    I'm trying to list some information about tasks and when I'm trying to set a date/time entry, I'm only able to edit the date part, not the time part.

    I've tried to change the DataEditFormatString to be able to change the time part but without success.

    What am I doing wrong?

    Here is a code of one of the GridViewDateTimeColumn.

                gridViewDateTimeColumn1.DataEditFormatString = "{0:D}"
                gridViewDateTimeColumn1.DataType = typeof(System.DateTime); 
                gridViewDateTimeColumn1.FieldAlias = "DateBegin"
                gridViewDateTimeColumn1.FieldName = "DateBegin"
                gridViewDateTimeColumn1.HeaderText = "DateBegin"
                gridViewDateTimeColumn1.IsAutoGenerated = true
                gridViewDateTimeColumn1.UniqueName = "DateBegin"
                gridViewDateTimeColumn1.Width = 140; 

    Thanks,
  2. Emmanuel Dugas-Gallant
    Emmanuel Dugas-Gallant avatar
    8 posts
    Member since:
    Mar 2010

    Posted 07 Jul 2010 Link to this post

    Is there anybody there that can help me with this issue?

    Thanks!
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Alexander
    Admin
    Alexander avatar
    306 posts

    Posted 08 Jul 2010 Link to this post

    Hello Emmanuel,

    Thank you for your question.

    It is a known issue in the current version of RadGridView. We will address it in a next version.

    Meantime, you can implement a custom RadDateTimeEditor which defines the format string that you need:

    public class CustomRadDateTimeEditor : RadDateTimeEditor
    {
        public override void Initialize(object owner, object value)
        {
            base.Initialize(owner, value);
     
            base.CustomFormat = "dd/MM/yyyy HH:mm:ss";
        }
    }

    Please use the EditorRequired event to change the used editor for the GridViewDateTimeColumn:

    private void radGridView1_EditorRequired(object sender, EditorRequiredEventArgs e)
    {
        if (e.EditorType == typeof(RadDateTimeEditor))
        {
            e.EditorType = typeof(CustomRadDateTimeEditor);
        }
    }

    I hope it helps.

    Best wishes,
    Alexander
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top