Przemyslaw
Top achievements
Rank 1
Przemyslaw
asked on 05 Nov 2009, 01:55 PM
Hi
I attach events to my GridView rows. The MouseWheel event works and the MessageBox shows up when I rotate the mouse wheel. However, the MouseLeftButtonDown event does NOT work. This seemed to work before I upgraded the project from Q2. Could you please let me know if I am doing something wrong or if there is a bug in this release.
//Constructor
public Player_GridView(int userid)
{
[...]
RowLoaded += SetDescriptions;
}
private void SetDescriptions(object sender, RowLoadedEventArgs e)
{
e.Row.MouseLeftButtonDown += Row_Clicked;
e.Row.MouseWheel += Row_MouseWheel;
}
private void Row_Clicked(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("Mouse down");
}
void Row_MouseWheel(object sender, MouseWheelEventArgs e)
{
MessageBox.Show("MouseWheel");
}
Przemek
I attach events to my GridView rows. The MouseWheel event works and the MessageBox shows up when I rotate the mouse wheel. However, the MouseLeftButtonDown event does NOT work. This seemed to work before I upgraded the project from Q2. Could you please let me know if I am doing something wrong or if there is a bug in this release.
//Constructor
public Player_GridView(int userid)
{
[...]
RowLoaded += SetDescriptions;
}
private void SetDescriptions(object sender, RowLoadedEventArgs e)
{
e.Row.MouseLeftButtonDown += Row_Clicked;
e.Row.MouseWheel += Row_MouseWheel;
}
private void Row_Clicked(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("Mouse down");
}
void Row_MouseWheel(object sender, MouseWheelEventArgs e)
{
MessageBox.Show("MouseWheel");
}
Przemek
5 Answers, 1 is accepted
0
Hi Przemyslaw,
All the best,
Milan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
The latest version of RadGridView handles the MouseLeftButtonDown and MouseLeftButtonUp events and as a result the your existing code is not able to handle those events.
You can workaround this problem by subscribing to MouseDown eventin code which gives the option to handle already handled events. For example:
public
Window1()
{
this
.InitializeComponent();
this
.gridView.AddHandler(GridViewCell.MouseLeftButtonDownEvent,
new
MouseButtonEventHandler(OnGridMouseLeftButtonDown),
true
);
}
private
void
OnGridMouseLeftButtonDown(
object
s, MouseButtonEventArgs args)
{
var senderElement = (FrameworkElement)args.OriginalSource;
var clickedRow = senderElement.ParentOfType<GridViewRow>();
if
(clickedRow !=
null
)
{
// execute logic
}
}
Hope this helps.
All the best,
Milan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Przemyslaw
Top achievements
Rank 1
answered on 05 Nov 2009, 06:07 PM
Hi Milan
thank you for your response. I will refactor my code tomorrow. I have a further question or clarification. You have written that the MouseLeftButtonDown (Up) events are handled by the RadGridView control and therefore the user code is not able to handle these events itself. However, my further investigation and trials showed that when I click on the very verge of a row (almost on the line separating two rows) then the MouseLeftButtonDown event handler in MY code IS actually executed. Is that a correct behavior?
Przemek
0
Hi Przemyslaw,
Milan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Well, actually it is the cells that handle most of the mouse event but the row separating lines are actually part of the rows themselves which do not handle mouse events (like Up, Down). In short, for the time being the behavior that you have described is expected.
Hope the information is helpful.
All the best,Milan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Marcus Lambert
Top achievements
Rank 1
answered on 30 Nov 2009, 05:31 PM
Hi,
I am suffering from this problem as well and it it not clear what the options are now.
I take it that we cannot use MouseLeftButtonDown & MouseLeftButtonUp
Please could someone list in post what the current opttion for mouse clicks on the grid are. The current sticky needs more detail.
I was wireing up a command in prism in the xaml to my ViewModel. now it looks like I cant do that now as every solution is code behind.
Marcus
I am suffering from this problem as well and it it not clear what the options are now.
I take it that we cannot use MouseLeftButtonDown & MouseLeftButtonUp
Please could someone list in post what the current opttion for mouse clicks on the grid are. The current sticky needs more detail.
I was wireing up a command in prism in the xaml to my ViewModel. now it looks like I cant do that now as every solution is code behind.
Marcus
0
Hi Marcus Lambert,
All the best,
Milan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Could you please check the response to your last question on this thread
All the best,
Milan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.