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

How can I intercept a "SelectionChanging" event?

4 Answers 80 Views
TimeBar
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 2
David asked on 27 Jul 2011, 11:39 AM
Hi,

I'm wondering whether I can intercept a "SelectionChanging" event. While there is a "SelectionChanged" event exposed, I would like to implement my own custom logic to manipulate SelectionStart and SelectionEnd when the user changes the selection before the changes are committed. The logic I would like to implement is for the SelectionStart and SelectionEnd to snap to the nearest hour if the selection period is less than a day, or snap to the nearest day if the selection period is over a day (This logic is more complex than what the IsSnapToIntervalEnabled property provides). While I can change the SelectionStart and SelectionEnd in the SelectedChanged event, this causes the SelectedChanged event to trigger again when I change one of these values.

Kind regards,
Dave.

4 Answers, 1 is accepted

Sort by
0
Accepted
Tsvetie
Telerik team
answered on 29 Jul 2011, 11:52 AM
Hello David,
Currently, the RadTimeBar control does not offer the functionality you need. I will forward your request to our developers and we will consider your suggestion.

Greetings,
Tsvetie
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Douwe
Top achievements
Rank 1
answered on 26 Apr 2016, 01:40 PM

Hello,

Is there any news related to this topic? We are also using the IsSnapToIntervalEnabled setting but the issue is that when there are incomplete intervals (e.g. hours) at the beginning and end of the complete time interval (while viewing day intervals) it is not possible to select these hours (because the snapping is on day intervals).

Best regards,

Douwe

0
Martin Ivanov
Telerik team
answered on 29 Apr 2016, 08:21 AM
Hello,

No such behavior is not yet implemented. However, to prevent the default selection interaction you can handle the MouseMove event of the timebar control. Then you can implement custom behavior that changes the SelectionStart and SelectionEnd based on your conditions. You can use the ConvertPointToDateTime() method of the timebar to get the mouse position as a date in the timeline.
void timeBar_PreviewMouseMove(object sender, MouseEventArgs e)
{
    // change the selection range
    e.Handled = true;  
}

Regards,
Martin
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Douwe
Top achievements
Rank 1
answered on 25 May 2016, 10:10 AM

Dear Martin,

Thank you for the tip, I will look into this to see if I can use this to implement the desired behavior.

Kind regards,

Douwe

Tags
TimeBar
Asked by
David
Top achievements
Rank 2
Answers by
Tsvetie
Telerik team
Douwe
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or