Hi,I am using an UltraGrid to show data and columns are a lot so the grid became larger than screen.
A scroll bar appeared automatically at the bottom so it is possible to slide horizontally the grid.
Because I have this set:ultraGridBand1.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.RowSelect;what happen when directional key are pressed is moving through cells, but selection is on an entire row so there are no differences between up-down and left-right: you jump current positioning between rows.
I would like to still use up-down arrow keys to move selected row, and to use left-right arrow keys to slidehorizontally the grid just like using the scroll bar.
I tryied a little bit without success and looked through forums, but found no interesting posts or advices.
Please could you tell me how I can obtain that behaviour?
Thanks in advance.
Gianni
Yes Mike, it is exactly what I have done.I found that action is the same between Keys.Up and Keys.Left and between Keys.Down and Keys.Right .
So this is what I have written:
private Keys currentDownKey = Keys.None;
this.ultraGrid1.KeyDown += new KeyEventHandler(ultraGrid1_KeyDown);this.ultraGrid1.KeyUp += new KeyEventHandler(ultraGrid1_KeyUp);this.ultraGrid1.BeforePerformAction += new BeforeUltraGridPerformActionEventHandler(ultraGrid1_BeforePerformAction);
void ultraGrid1_BeforePerformAction(object sender, BeforeUltraGridPerformActionEventArgs e){ if ((e.UltraGridAction==UltraGridAction.NextRow && this.currentDownKey == Keys.Right) || (e.UltraGridAction==UltraGridAction.PrevRow && this.currentDownKey == Keys.Left) ) { e.Cancel = true; }}void ultraGrid1_KeyDown(object sender, KeyEventArgs e){ this.currentDownKey = e.KeyData; if (e.KeyData == Keys.Right) { this.ultraGrid1.ActiveColScrollRegion.Scroll(ColScrollAction.Right); } else if (e.KeyData == Keys.Left) { this.ultraGrid1.ActiveColScrollRegion.Scroll(ColScrollAction.Left); }}void ultraGrid1_KeyUp(object sender, KeyEventArgs e){ this.currentDownKey = Keys.None;}
I want to thank you very much for your ideas and for your really fast replying .
Regards
GiannisKhan said:but it will work only if actions performed with Keys.Left and Keys.Right are different from actions performed with Keys.Up and Keys.Down
Yes, that's a valid concern. I didn't check what actions are performed. But it should be simple enough to put a breakpoint in the event and then press a key to see which action is triggerred.
There are so many event you can catch that sometimes I get lost ! This way sounds very easy, but it will work only if actions performed with Keys.Left and Keys.Right are different from actions performed with Keys.Up and Keys.Down . (Because Keys.Up and Keys.Down has to preserve their behaviors)
I'm going to try.
However I could put a flag to know what key were pressed, not too much elegant, but could work...
Thank you very much.
You don't want to use GetGetActionMappings here. What you need to do is loop through the KeyActionMapping collection and remove the items you want. It's a good idea to do this backwards so that you do not affect the collection as you are looping.
In any case, I think there's an easier way. What I would do is handle the grid's BeforePerformAction event. You can trap for the action that occurs when you use the left or right arrow keys, then cancel the event and use grid.ActiveColScrollRegion to scroll the grid in the appropriate direction.
Brian, I am not able to do what you proposed.I thought to remove Keys.Left and Keys.Right mapping using:this.ultraGrid1.KeyActionMappings.Remove ( x )Where x is type of KeyActionMappingBase.I tried to obtain x by KeyActionMappingBase[] xCollection = this.ultraGrid1.KeyActionMappings.GetActionMappings(Keys.Right, 0 , SpecialKeys.All);but it returned an empty array ...Please could you tell me where I'm wrong and write some example code lines ?I would appreciate it a lot.Thanks againGianni