Arrow click event

4 posts, 0 answers
  1. Dominik
    Dominik avatar
    59 posts
    Member since:
    Dec 2012

    Posted 17 Jan 2013 Link to this post

    Hi,

    I need to know when user used arrows for changing value.

    Create new project, drop RadDateTimePicker, double click on form to create Load and paste this code:

    private void Form1_Load(object sender, EventArgs e)
    {
        radDateTimePicker1.Format = DateTimePickerFormat.Time;
        radDateTimePicker1.ShowUpDown = true;
     
        radDateTimePicker1.MouseDown += radDateTimePicker1_MouseDown;
        radDateTimePicker1.DateTimePickerElement.MouseDown += DateTimePickerElement_MouseDown;
        radDateTimePicker1.DateTimePickerElement.TextBoxElement.MouseDown += TextBoxElement_MouseDown;
        radDateTimePicker1.ValueChanged += radDateTimePicker1_ValueChanged;
    }
     
    void radDateTimePicker1_ValueChanged(object sender, EventArgs e)
    {
        Console.WriteLine("value changed: " + radDateTimePicker1.Value);
    }
     
    void TextBoxElement_MouseDown(object sender, EventArgs e)
    {
        Console.WriteLine("radDateTimePicker1.DateTimePickerElement.TextBoxElement");
    }
     
    void DateTimePickerElement_MouseDown(object sender, EventArgs e)
    {
        Console.WriteLine("radDateTimePicker1.DateTimePickerElement");
    }
     
    void radDateTimePicker1_MouseDown(object sender, MouseEventArgs e)
    {
        Console.WriteLine("radDateTimePicker1");
    }

    Only radDateTimePicker1_MouseDown work when you click on arrow but this occurred after radDateTimePicker1_ValueChanged.
    I my case i need to know when user clicked arrow before changing value.

    I also try to add this event
    radDateTimePicker1.DateTimePickerElement.ArrowButton.Click += ArrowButton_Click;

    ... but ArrowButton object is null.

    Please give me some advice how to check if user click arrows before value was changed.



  2. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 18 Jan 2013 Link to this post

    Hello Dominik,

    Thank you for writing.

    You can get the Up/Down buttons in this way:
    RadDateTimePickerSpinEdit spinEdit = radDateTimePicker1.DateTimePickerElement.GetCurrentBehavior() as RadDateTimePickerSpinEdit;
    RadRepeatArrowElement upButton = spinEdit.ButtonsLayout.Children[0] as RadRepeatArrowElement;
    RadRepeatArrowElement downButton = spinEdit.ButtonsLayout.Children[0] as RadRepeatArrowElement;
     
    upButton.Click+=...

    I hope this helps. Regards,
    Peter
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Dominik
    Dominik avatar
    59 posts
    Member since:
    Dec 2012

    Posted 22 Jan 2013 Link to this post

    Hello Peter,

    Thank you for writing.


    'Telerik.WinControls.UI.RadDateTimePickerSpinEdit' does not contain a definition for 'ButtonsLayout' and no extension method 'ButtonsLayout' accepting a first argument of type 'Telerik.WinControls.UI.RadDateTimePickerSpinEdit' could be found (are you missing a using directive or an assembly reference?)

    In reference i have:
    Telerik.WinControls
    Telerik.WinControls.UI
    TelerikCommon

    Version: 2012.3.1017.40
  5. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 23 Jan 2013 Link to this post

    Hi Dominik,

    I am sorry for the inconvenience. 
    For your version the relevant code is:
    RadDateTimePickerSpinEdit spinEdit = radDateTimePicker1.DateTimePickerElement.GetCurrentBehavior() as RadDateTimePickerSpinEdit;
    RadRepeatArrowElement upButton = spinEdit.DateTimePickerElement.Children[2].Children[2].Children[0] as RadRepeatArrowElement;
    RadRepeatArrowElement downButton = spinEdit.DateTimePickerElement.Children[2].Children[2].Children[1] as RadRepeatArrowElement;

    Let me know if you have further questions.
    Kind regards,
    Peter
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
Back to Top