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

Arrow click event

3 Answers 206 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
konrad
Top achievements
Rank 1
konrad asked on 17 Jan 2013, 05:07 PM
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.



3 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 18 Jan 2013, 09:28 AM
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.
0
konrad
Top achievements
Rank 1
answered on 22 Jan 2013, 08:15 AM
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
0
Peter
Telerik team
answered on 23 Jan 2013, 08:42 AM
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.
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
konrad
Top achievements
Rank 1
Answers by
Peter
Telerik team
konrad
Top achievements
Rank 1
Share this question
or