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
Hi Paul,
When you select an item from the list, the cell remains in edit mode. So the MouseWheel is handled by the cell's editor instead of by the grid. This is not different then if you tabbed into that cell or clicked on it without selecting a value.
Do you want to prevent the mouse wheel from working in ALL of those cases? Or just this one particular case?
If it's just this one case, then the thing to do would be to force the cell out of edit mode. But this will be very tricky and kinda weird for the user. first off, it will be very difficult to detect when the user is really "done" editing the cell. Suppose they drop down the list, pick an item, and then change their mind and try to type in the cell. If it's not in edit mode any more, then typing won't work. There is also no way to tell if the user drops down the list and picks something or drops down the list and clicks on some other cell without choosing anything. You can reliably detect when the list closes, though. So if you want to explore this option, you could do something like this:
private void ultraGrid1_AfterCellListCloseUp(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e) { UltraGrid grid = (UltraGrid)sender; grid.PerformAction(UltraGridAction.ExitEditMode); }
If you want to prevent the editor from handling the MouseWheel in all cases, then I'm not sure if that's possible. I would have to look into it some more.
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
Hi,
I tried this out and I can't get the behavior you describe. The mouse wheel has no effect on a column where the CellActivation is set to ActivateOnly. When I use the wheel in a case like this, the grid scrolls, and the value of the cell does not change, which seems like correct behavior.
I'm attaching my sample here so you can try it and see if you get the same results.
Mike, could you send the sample in a different way? (Zip, with the extension changed to zi_ might work) I believe our zealous Corporate email security software is stripping the attachment without giving me the option to retrieve it.
I should also mention that I am specifically using an UltraCombo as the Editor, and the latest release of Infragistics WinForms (13.2, updated 2 days ago)
The forums will not allow me to update a file with an unknown extension like that.
Only files with the following extensions are allowed: zip, cab, jpg, gif, png, mpg, mpeg, avi, wmv, wma, mp3, ra, rar, rm, sql, txt.
All I did was put a grid on a form and bind it to a DataSource that has an integer field with values from 0 to 4.
Then I did this:
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridBand band = layout.Bands[0]; ValueList vl = new ValueList(); vl.ValueListItems.Add(0, "Apple"); vl.ValueListItems.Add(1, "Banana"); vl.ValueListItems.Add(2, "Cherry"); vl.ValueListItems.Add(3, "Grape"); vl.ValueListItems.Add(4, "Watermelon"); band.Columns["Int32 1"].ValueList = vl; band.Columns["Int32 1"].CellActivation = Activation.ActivateOnly; }
Not a problem; I see what you're doing and I agree, with a value list this problem does not occur. However, i'm setting the EditorComponent to an UltraCombo; this is when I'm seeing the undesired scroll behavior with CellActivation set to ActivateOnly
I tried this out with UltraCombo and it still works just fine for me. I don't have any problem with the mouse wheel.The mouse wheel still scrolls the grid and doesn't change the cell value.
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridBand band = layout.Bands[0]; UltraGridOverride ov = layout.Override; UltraCombo cbo = new UltraCombo(); this.Controls.Add(cbo); DataTable dt = new DataTable(); dt.Columns.Add("Key", typeof(int)); dt.Columns.Add("Name", typeof(string)); dt.Rows.Add(new object[] { 0, "Apple" }); dt.Rows.Add(new object[] { 1, "Banana" }); dt.Rows.Add(new object[] { 2, "Cherry" }); dt.Rows.Add(new object[] { 3, "Grape" }); dt.Rows.Add(new object[] { 4, "Watermelon" }); cbo.DataSource = dt; cbo.ValueMember = "Key"; cbo.DisplayMember = "Name"; band.Columns["Int32 1"].EditorComponent = cbo; band.Columns["Int32 1"].CellActivation = Activation.ActivateOnly; }
Why are you using UltraCombo and EditorComponent? That will work, of course, but it's not a very efficient way to do it. Unless you need the combo to provide editor buttons or multi-select, it would be better to use UltraDropDown as the ValueList of the column.