When an UltraDropDown is activated (i.e. single clicked) in my grid and the mouse scroll wheel moved the selected value in the UltraDropDown changes even though it has not dropped down. Typically my users are just wanting to scroll the grid in this situation. What do I need to change to make the grid scroll and not the UltraDropDown in this situation?
I am currently using 2007 Vol. 2 but can switch to the latest release if necessary.
dwolf81 said:Thanks for posting this, really helped me out. Instead of saving the orignal value and reseting it you can actually just do a UltraGrid1.ActiveCell.CancelUpdate().
No problem. I still hope that Infragistics at least gives us an option to do something like this standard.
I tried the CancelUpdate() thing, but that doesnt work quite the way I want it to. If the user selects a value from the drop down, and then scrolls down, it will revert back to the original value - not the one the user selected. I want it to stay on the value the user selected.
Thanks for posting this, really helped me out. Instead of saving the orignal value and reseting it you can actually just do a UltraGrid1.ActiveCell.CancelUpdate().
Its funny that you should ask that now. After working on this issue off and on since my previous post (5+ months), I finally arrived at a solution last night. Its dissapointing that I had to spend so much time (I would guess days) to acheive what I beleive should be standard functionality (or at least a standard option). But as far as I'm concerned, I couldnt release the application the way it was - it would just casue to many problems.
Anyway, enough with my rant, onto the solution. I created a class to do this, to save writing it in each form individually.
declare an object varaible to store the value of the dropdown field:
private object _dropdownValue;
Then I add a ControlAdded event (ugSender is an UltraGrid):
ugSender.ControlAdded += new ControlEventHandler(ugSender_ControlAdded);
In ControlAdded event, put the code:
void ugSender_ControlAdded(object sender, ControlEventArgs e)
{
string contType = sender.GetType().ToString();
UltraGrid ugSender = sender as UltraGrid;
UltraDropDown uddSender = ugSender.ActiveCell.ValueListResolved as UltraDropDown;
if (uddSender != null)
e.Control.MouseWheel += new MouseEventHandler(Control_MouseWheel);
e.Control.Enter += new EventHandler(Control_Enter);
uddSender.AfterCloseUp += new DropDownEventHandler(uddSender_AfterCloseUp);
}
The uddSender_AfterCloseUp event looks like this:
void uddSender_AfterCloseUp(object sender, DropDownEventArgs e)
UltraDropDown uddSender = sender as UltraDropDown;
_dropdownValue = _ultraGrid.ActiveCell.Value;
The Control_Enter event looks like this:
void Control_Enter(object sender, EventArgs e)
Control conSender = sender as Control;
UltraGrid ugSender = conSender.Parent as UltraGrid;
if (ugSender != null)
UltraDropDown dropdown = ugSender.ActiveCell.ValueListResolved as UltraDropDown;
if (dropdown != null)
And the Control_MouseWheel event looks like this:
void Control_MouseWheel(object sender, MouseEventArgs e)
_ultraGrid.ActiveCell.Value = _dropdownValue;
ugSender.PerformAction(UltraGridAction.ExitEditMode, false, false);
Whats happening here is:
A few points.
I havnt really accounted for the user selecting a value by other means. I'm assuming if the user selects a value by typing something in, they will tab or enter to select it, which will then move the focus to another field - so there is no real issue here (I think).
I havnt really tested this a great deal. As I said, I just worked out this solution last night, so only basic testing has been done so far. If you find ways to improve it, please post it back here!
--- EDIT ---
The Control_MouseWheel event needs a little additional code, so that both of the lines:
Are within another conditional statement
if (!dropdown.IsDroppedDown)
I did say I hadnt tested it much...
I haven't had the time to look into this problem any further and I haven't heard any other suggestions.
Are there any news about this Problem?
Thanks for reply!