Hello,
I have an UltraGrid with a column called 'LandCodes'. I set the ValueList of this column and set the Style to ColumnStyle.DropDownList.
The scenario is:I select a value from the drop down for a 'LandCodes' cellI then scroll the mouse wheel
Currently this causes the value in the cell to change.
The behaviour I am looking for is the value no remain the same but for the grid to scroll.
Any help would be greatly appreciated.
Thanks,Paul
That sounds slightly more painful than the 200 or so lines of code from the post you reference above where the mouse wheel MAY be handled in most cases when the dropdown display is not up.
Is there a better solution for this now? I'm noticing that even when cellActivation is set to ActivateOnly, the editor component still scrolls through it's list. I can disable the scroll behavior altogether by setting the CellActivation to NoEdit, but I would prefer to allow users to copy the value from the cell. Will we see a fix that actually prevents the cell's value from changing when ActivateOnly is set, regardless of the editor?
Hi Paul,
My apologies, I misread the post I linked to. I didn't realize it was still using the TextBox. So that's actually no different than what you already did.
In DropDownList mode, there is no TextBox. You don't need one, since you can't type into the cell.
I did some investigating and it looks like what's happening in this case is that the Editor is actually listening in to the MouseWheel event of the the owning control - in this case the grid. So if you handle the grid's MouseWheel event, you are listening to the same event the editor is using and you cannot be sure that you will get the event before the editor does.
So the only reliable way to handle this would be to derive a class from the WinGrid and override the OnMouseWheel method. Then you could check the current state of the grid and if there is nothing dropped down, set e.Handled to True before calling the base.
Hi,
My code does handle the MouseWheel on the editor in addition the code in the example given doesn't work for DropDownList columns as tramp168 says.
Using the example the 'TextBox_MouseWheel' function is never called when you scroll the mouse in a cell which contains a drop down list (the value of the cell simply changes). The 'TextBox_MouseWheel' function is called if you scroll the mouse in a standard text cell but obviously that isn't helpful in this case.
It appears to me that the editor.TextBox is not the control I need to be handling the MouseWheel event for. What control is used in the grid for a DropDownList and is this control assesible in any way so I can handle the MouseWheel event on it?
You need to handle the MouseWheel on the editor, not on the grid. There's sample code showing how to do this here:
How to let the cellvalue not changed together when scrolling the wheel of the mouse - NetAdvantage for Windows Forms - Grids
Hi Mike,
Ideally I would like to prevent the mouse wheel from affecting the cell when ever the drop down list is not shown.
Some of my users are selecting a value from the drop down (either with the mouse or using the keyboard) and then attempt to use the mouse scroll wheel to scroll down the grid. Obviously it won't scroll but the problem is sometimes they do this and don't realise they've changed the value in the cell.
My initial solutions was as below but it doesn't work. The ControlAdded code runs and adds the handle but the ctrl_MouseWheel function is never called.
private bool allowCellScroll;
private void gridFdp_BeforeCellListDropDown(object sender, CancelableCellEventArgs e){ this.allowCellScroll = true;}private void gridFdp_AfterCellListCloseUp(object sender, CellEventArgs e){ this.allowCellScroll = false;}
allowCellScroll
this.allowCellScroll = false;
private void gridFdp_ControlAdded(object sender, ControlEventArgs e){ Infragistics.Win.UltraControlBase ctrl = e.Control as Infragistics.Win.UltraControlBase; if (ctrl != null) ctrl.MouseWheel += new MouseEventHandler(ctrl_MouseWheel);}
private void ctrl_MouseWheel(object sender, MouseEventArgs e){ HandledMouseEventArgs args = e as HandledMouseEventArgs; if (args != null && !this.allowCellScroll) args.Handled = true;}
this.allowCellScroll