4 Answers, 1 is accepted
0
Accepted
Hi Karl,
Thank you for your question.
You can achieve this by handling the MouseClick event of RadScheduler and detecting which element was clicked. The following code snippet demonstrates this:
I hope you find this useful. Feel free to ask if you have any additional questions.
Regards,
Ivan Todorov
the Telerik team
Thank you for your question.
You can achieve this by handling the MouseClick event of RadScheduler and detecting which element was clicked. The following code snippet demonstrates this:
void radScheduler1_MouseClick(object sender, MouseEventArgs e){ SchedulerResourcesHeaderElement resourceHeader = this.radScheduler1.RootElement.FindDescendant<SchedulerResourcesHeaderElement>(); if (resourceHeader != null && resourceHeader.ControlBoundingRectangle.Contains(e.Location)) { SchedulerCellElement clickedCell = this.radScheduler1.ElementTree.GetElementAtPoint(e.Location) as SchedulerCellElement; if (clickedCell != null) { foreach (Resource res in this.radScheduler1.Resources) { if (res.Name == clickedCell.Text) { RadMessageBox.Show("You have clicked ResourceId: " + res.Id.KeyValue); break; } } } }}I hope you find this useful. Feel free to ask if you have any additional questions.
Regards,
Ivan Todorov
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
John
Top achievements
Rank 1
answered on 18 Sep 2013, 04:57 PM
is there anyway to get the resource id from the clickedCell object?
this
would only work if all the resources had different text. I have multiple resources that have the same cell text so it's always just pulling the first one.
Thanks!
this
if (res.Name == clickedCell.Text) {would only work if all the resources had different text. I have multiple resources that have the same cell text so it's always just pulling the first one.
Thanks!
0
Hello John,
Thank you for contacting Telerik Support.
You are able to modify the previous code snippet as follows:
Please, have in mind that this code example is related to RadScheduler DayView.
I hope this information helps. Should you have further questions, I would be glad to help.
Regards,
Desislava
Telerik
Thank you for contacting Telerik Support.
You are able to modify the previous code snippet as follows:
private void radSchedulerControl_MouseClick(object sender, MouseEventArgs e){ SchedulerResourcesHeaderElement resourceHeader = this.radSchedulerControl.RootElement.FindDescendant<SchedulerResourcesHeaderElement>(); if (resourceHeader != null && resourceHeader.ControlBoundingRectangle.Contains(e.Location)) { SchedulerCellElement clickedCell = this.radSchedulerControl.ElementTree.GetElementAtPoint(e.Location) as SchedulerCellElement; if (clickedCell != null) { GetResource(); } }}public void GetResource(){ Point point = radSchedulerControl.PointToClient(Cursor.Position); SchedulerDayViewGroupedByResourceElement groupedDayViewElement = radSchedulerControl.SchedulerElement.ViewElement as SchedulerDayViewGroupedByResourceElement; if (groupedDayViewElement == null) { return; } foreach (SchedulerDayViewElement dayViewElement in groupedDayViewElement.GetDayViewElements()) { int min = dayViewElement.ControlBoundingRectangle.X; int max = min + dayViewElement.ControlBoundingRectangle.Width; if (point.X >= min && point.X <= max) { EventId resource = dayViewElement.View.GetResources()[0].Id; MessageBox.Show(resource.KeyValue.ToString()); return; } }}Please, have in mind that this code example is related to RadScheduler DayView.
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 >>
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 >>
0
John
Top achievements
Rank 1
answered on 23 Sep 2013, 01:17 PM
Thanks that worked great
