I was wondering if it's possible with a RadGridView to have the double click event not enable edits on the cell ?
Single click edits work fine, but double clicks activate another view, and I do not want the cell being in an editable state at this point.
A possible approach is to use the BeginningEdit event to cancel the edit of the cell, when the double click occurs. In order to do that you can do the following:
1) set two Boolean flags(isEditMouseInitiated and isDoubleClick). Where isEditMouseInitiated and isDoubleClick are used to indicate, respectively that an edit operation was initiated by a mouse activity and you have a double click. 2) add a handlers for the MouseDoubleClickEvent and MouseLeftButtonUpEvent events, to set the Boolean flags to the appropriate values - isDoubleClick is set to false, when the MouseDoubleClickEvent event triggers and the isEditMouseInitiated is set to true, when the MouseLeftButtonUpEvent triggers.
bool isDoubleClick = true;
bool isEditMouseInitiated = true;
DispatcherTimer dispatcherTimer = new DispatcherTimer();
public MainWindow()
{
InitializeComponent();
this.AddHandler(Control.MouseDoubleClickEvent, new MouseButtonEventHandler((s, e) =>
{
isDoubleClick = false;
}), true);
this.AddHandler(Control.MouseLeftButtonUpEvent, new MouseButtonEventHandler((s, e) =>
{
isEditMouseInitiated = true;
}), true);
}
3) use a DispatcherTimer in the BeginingEdit event handler to set an interval of time and attach an event handler to it's Tick event to detect if a second click has occurred. If the isDoubleClick flag or the IsEnabled property of the DispatcherTimer are set to false the GridView will not enter edit mode.
Also, I attached a sample project that demonstrates the suggested approach.
I hope this helps.
Regards,
Boris Penev
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.