GridTimePickerEditor

7 posts, 0 answers
  1. pierre-jean
    pierre-jean avatar
    114 posts
    Member since:
    Apr 2011

    Posted 17 Oct 2017 Link to this post

    I have a databound gridview with a column containing time a time value and I have inserted the below code to allow editing the time in the cell

    1. The editing works fine, but when I enter the cell the displayed value is {0:09:45} is this normal ? is it possible to change it to 09:45 ?

    2. is it possible to modify the column width when it enters in edit mode otherwise the timepicker editor is shrunk

    3. How do I change the TimeEditor to display times in 24hrs instead of AM/PM ?

    Thanks 

     

        Private Sub gvShow_EditorRequired(sender As Object, e As EditorRequiredEventArgs) Handles gvShow.EditorRequired
            If gvShow.CurrentColumn.Name = "StartTime" Then e.Editor = New GridTimePickerEditor
        End Sub

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3759 posts

    Posted 20 Oct 2017 Link to this post

    Hello, Pierre-Jean,  

    Thank you for writing.  

    Please refer to the following code snippet demonstrating how to specify the time format for the grid cells and the editor. The result is illustrated in the attached screenshot:
    Sub New()
     
        InitializeComponent()
     
        Dim dateTimeColumn As New GridViewDateTimeColumn("DateTimeColumn")
        dateTimeColumn.FormatString = "{0:HH:mm}" ' format for the cells
        dateTimeColumn.Format = DateTimePickerFormat.Custom
        dateTimeColumn.CustomFormat = "HH:mm"
        Me.RadGridView1.Columns.Add(dateTimeColumn)
        Me.RadGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill
     
        For index = 1 To 10
            Me.RadGridView1.Rows.Add(DateTime.Now.AddHours(index).AddMinutes(index))
        Next
     
        AddHandler Me.RadGridView1.EditorRequired, AddressOf EditorRequired
    End Sub
     
    Private Sub EditorRequired(sender As Object, e As EditorRequiredEventArgs)
        If Me.RadGridView1.CurrentColumn.Name = "DateTimeColumn" Then e.Editor = New GridTimePickerEditor
    End Sub

    Additional information for the GridViewDateTimeColumn is available here: https://docs.telerik.com/devtools/winforms/gridview/columns/column-types/gridviewdatetimecolumn

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. pierre-jean
    pierre-jean avatar
    114 posts
    Member since:
    Apr 2011

    Posted 20 Oct 2017 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Thank you for your message, but I have not been able to make it work.

    the difference might be in the fact that I have a databound grid and the column data comes from the table.

    I have added the follwing code

            InitializeComponent()
            ' Ajoutez une initialisation quelconque après l'appel InitializeComponent().
            AddHandler gvShow.EditorRequired, AddressOf EditorRequired

    'CALLED after databinding
                Dim TimeCol As New GridViewDateTimeColumn
                TimeCol = gvShow.MasterTemplate.Columns("StartTime")
                TimeCol.FormatString = "{0:HH:mm}"
                TimeCol.Format = DateTimePickerFormat.Custom
                TimeCol.CustomFormat = "HH:mm"
                TimeCol.AutoSizeMode = GridViewAutoSizeColumnsMode.Fill
    .....

        Private Sub EditorRequired(sender As Object, e As EditorRequiredEventArgs) Handles gvShow.EditorRequired
            If gvShow.Tag = "CO" And gvShow.CurrentColumn.Name = "StartTime" Then e.Editor = New GridTimePickerEditor
        End Sub

    and:

    1. The column does displays in time correct format (see screenShot1)

    2. but When I clic on the "clock" the time displayed is not in "HH:mm" (24hrs) format and the column width is too small (See Screen Shot 2)

     

  4. pierre-jean
    pierre-jean avatar
    114 posts
    Member since:
    Apr 2011

    Posted 20 Oct 2017 in reply to pierre-jean Link to this post

    Just a few additional information:

    1. I have tried to set the culture info to "fr-FR" which, displays time in 24hr formats -> No Change

    2. In de detail pane of my object I use the datetimepicker control and I get the correct behavior (see ScreenShot3)

    Thanks in advance

     

  5. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3759 posts

    Posted 23 Oct 2017 Link to this post

    Hello, Pierre-Jean,    

    Thank you for writing back. 

    Depending on the applied culture to the RadTimePickerElement the hours in the drop down are filled. If AMDesignator/PMDesignator are not empty in the culture, the AM/PM section is shown in the popup. Please refer to the attached sample project which result is illustrated in the attached screenshot.

    I hope this information helps. If you have any additional questions, please let me know. 

     Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  6. pierre-jean
    pierre-jean avatar
    114 posts
    Member since:
    Apr 2011

    Posted 23 Oct 2017 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Thanks a lot

    I had thought that the culture info would be passed from the form to the control and to the editor, but it works with your information.

    Thanks a lot

  7. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3759 posts

    Posted 24 Oct 2017 Link to this post

    Hello,  Pierre-Jean,    

    Thank you for writing back. 

    Indeed, you can specify the culture for the entire application by using the code snippet below. Thus, the time picker in the editor will consider it when populating the hours' table: 
    Dim culture As New System.Globalization.CultureInfo("en-GB")
    culture.DateTimeFormat.AMDesignator = ""
    culture.DateTimeFormat.PMDesignator = ""
    System.Threading.Thread.CurrentThread.CurrentCulture = culture

    I hope this information helps. If you have any additional questions, please let me know. 

     Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top