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

GridTimePickerEditor popup clock size

1 Answer 78 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Szymon
Top achievements
Rank 1
Szymon asked on 17 Oct 2013, 12:18 PM
Hi!

I would like to resize my gridtimepicker clock. Main issue is that by default its size hides minutes to choose. I have to resize the clock manually every time to show these options which is irritating. Default view in attachment. How can I solve this problem?

And in addition. How to change color of the hand of the clock? Eg. in Style Builder?

Thanks in advance,
Szymon.

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 22 Oct 2013, 10:02 AM
Hello Szymon,

Thank you for contacting Telerik Support.

Time picker popup default size is a known issue, which is already logged in our Public Issue Tracking System - PITS. You can track its progress, subscribe for status changes and add your vote/comment to it on the following link - PITS issue.

Currently, the possible workaround I can propose is to adjust manually PopupForm.Height of the RadTimePickerElement:
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
 
        List<MyObject> list = new List<MyObject>()
        {
            new MyObject(1,"sample name 1", DateTime.Now.AddHours(2).TimeOfDay),
            new MyObject(2,"sample name 2", DateTime.Now.AddHours(4).TimeOfDay),
            new MyObject(3,"sample name 3", DateTime.Now.TimeOfDay)
        };
        this.radGridView1.DataSource = list;
        this.radGridView1.EditorRequired += radGridView1_EditorRequired;
        this.radGridView1.CellEditorInitialized += radGridView1_CellEditorInitialized;
    }
 
    private void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
    {
        TimeEditor timeEditor = e.ActiveEditor as TimeEditor;
        if (timeEditor != null)
        {
            RadTimePickerElement editor = (RadTimePickerElement)timeEditor.EditorElement;
            editor.PopupForm.Height = 350;           
        }
    }
 
    private void radGridView1_EditorRequired(object sender, Telerik.WinControls.UI.EditorRequiredEventArgs e)
    {
        GridViewEditManager manager = sender as GridViewEditManager;
        if (manager != null && manager.GridViewElement.CurrentColumn.Name == "Time")
        {
            e.EditorType = typeof(TimeEditor);
        }
    }
}
 
public class MyObject
{
    public int ID { get; set; }
 
    public string Name { get; set; }
 
    public TimeSpan Time { get; set; }
 
    public MyObject(int iD, string name, TimeSpan time)
    {
        this.ID = iD;
        this.Name = name;
        this.Time = time;
    }
}
 
public class TimeEditor : BaseGridEditor
{
    public override object Value
    {
        get
        {
            RadTimePickerElement editor = (RadTimePickerElement)this.EditorElement;
            var dateValue = editor.Value as DateTime?;
            if (dateValue.HasValue)
            {
                return new TimeSpan(dateValue.Value.Hour, dateValue.Value.Minute, dateValue.Value.Second);
            }
 
            return TimeSpan.MinValue;
        }
        set
        {
            RadTimePickerElement editor = (RadTimePickerElement)this.EditorElement;
            if (value != null && value != DBNull.Value && value is TimeSpan)
            {
                var timeSpan = (TimeSpan)value;
                editor.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month,
                    DateTime.Now.Day, timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds);
            }
        }
    }
 
    public override void BeginEdit()
    {
        ((RadTimePickerElement)this.EditorElement).Culture = new System.Globalization.CultureInfo("en-GB");
        base.BeginEdit();
        ((RadTimePickerElement)this.EditorElement).ValueChanged += TimeEditor_ValueChanged;
        this.EditorElement.Focus();
    }
 
    private void TimeEditor_ValueChanged(object sender, EventArgs e)
    {
        OnValueChanged();
    }
 
    public override bool EndEdit()
    {
        ((RadTimePickerElement)this.EditorElement).ValueChanged -= TimeEditor_ValueChanged;
        return base.EndEdit();
    }
 
    protected override RadElement CreateEditorElement()
    {
        return new RadTimePickerElement();
    }
}

As to the question about the hands of clock, you can change the default image with an appropriate one using VisualStyleBuilder (please have a look at the attached picture "Arrows.png").

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

Regards,
Desislava
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Szymon
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or