DateTime column with TimePicker editor in Grid

3 posts, 1 answers
  1. Shlomo Pleban
    Shlomo Pleban avatar
    5 posts
    Member since:
    Oct 2006

    Posted 06 Mar 2013 Link to this post

    Hi,

    I defined a DateTime column with TimePicker editor in a grid.
    When I press the clock, the clock editor is opened, the problem is when I leave the cell without closing the editor (pressing the done, in some cases the editor is closed and in some times its still open, even when I am in a different cell (Decimal column for example). I can still change the time in the editor but it's not connect to anything.

    This is how I defined the column:
    var dateColumnOut = new GridViewDateTimeColumn
             {
                 HeaderText = "Date Time Out",
                 Name = Data.cJobCardData.JobCardColumns.DateTimeOut,
                 FieldName = Data.cJobCardData.JobCardColumns.DateTimeOut,
                 Format = DateTimePickerFormat.Long,
                 EditorType = GridViewDateTimeEditorType.TimePicker,
                 FormatString = "{0: M/d/yyyy h:mm tt}",
                 TextAlignment = ContentAlignment.MiddleCenter,
                 Width = colWidth
             };

    I checked the CurrentCellChange: The event is fired and I can fill the new cell values. Still, the clock editor is opened and I don't know how to close it.

    What am I doing wrong ????
  2. Answer
    Peter
    Admin
    Peter avatar
    1157 posts

    Posted 07 Mar 2013 Link to this post

    Hi Shlomo,

    Thank you for writing.

    I was able to reproduce the described behavior. 
    As a workaround you should close explicitly the RadTimePickerElement popup on CellEndEdit event. Please, refer to the code below:
    private void Form1_Load(object sender, EventArgs e)
    {
        ....
        this.radGridView1.CellEndEdit += new GridViewCellEventHandler(radGridView1_CellEndEdit);
        this.radGridView1.CellEditorInitialized += new GridViewCellEventHandler(radGridView1_CellEditorInitialized);
    }
     
    GridTimePickerEditor editor = null;
    void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
    {
        editor = e.ActiveEditor as GridTimePickerEditor;
    }
     
    void radGridView1_CellEndEdit(object sender, GridViewCellEventArgs e)
    {
        if (editor != null)
        {
            RadTimePickerElement element = (RadTimePickerElement)editor.EditorElement;
            element.ClosePopup();
        }
    }

    I hope this helps. Greetings,
    Peter
    the Telerik team
    WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
  3. Shlomo Pleban
    Shlomo Pleban avatar
    5 posts
    Member since:
    Oct 2006

    Posted 07 Mar 2013 Link to this post

    Thanks
Back to Top