When a user presses the 'Tab' key, I would like for the active cell to move 'down' instead of 'across'. To accomplish this, I've replaced the KeyActionMapping for my grid and replaced the 'NextCellByTab'/'PrevCellByTab' with 'BelowCell'/'AboveCell'. I did the same thing with NextRowByTab/PrevRowByTab - replacing those with 'BelowRow'/'AboveRow'.
When I press 'tab' the selected cell move down instead of over to the right; it is exactly what I want. When it reaches the bottom, it starts again at the top in the next column to the right. PERFECT!
When I press 'shift+tab' the select cell moves up, instead of over to the left; so far so good. However, when it reaches the top of ANY column, it stops. It won't go back to the previous column. So I can go through all of my cells, correctly, using the tab key - but 'Shift+tab' which performs the Above Cell action doesn't work the same way. It stops as soon as it hits the top of any column.
Can anyone tell me what I might have done wrong, or what I can do to get the shift+tab to perform exactly like the 'tab' key is - only in reverse?
Thanks!
kbamar83 said: on click of a tab key on the last column of a last row. I want a new row to be added to the ultrawebgrid
on click of a tab key on the last column of a last row. I want a new row to be added to the ultrawebgrid
You should post this question in the UltraWebGrid forum.
Hi there,
I have a to get the following function working.
on click of a tab key on the last column of a last row. I want a new row to be added to the
ultrawebgrid,
Hi Rob,
That does seem odd. I recommend reporting this to Infragistics Developer Support as a possible bug.
Submit a Support Issue
A follow up to the above....
If I put the following code into the BeforePerformAction event; everything works exactly how I want it to...
Public Sub UltraGrid1_BeforePerformAction(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.BeforeUltraGridPerformActionEventArgs) Handles UltraGrid1.BeforePerformAction If e.UltraGridAction = Infragistics.Win.UltraWinGrid.UltraGridAction.AboveCell Then e.Cancel = True UltraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.AboveCell) End If End Sub
Seems odd to me, but I thought it'd post it.
First - thanks for your response. The project I'm working in is fairly large and has all sorts of already written code that could be adding functionality to the grid; so to make things easier - I created a fresh project. I added an UltraGrid to my form...
I set the grid to allow the moving of columns and various other display type things and I create a dataTable consisting of 8 columns and 1 row that I set to the Grid's datasource. I then remove *all* of the Grid's KeyActionMappings for the 'Tab' key. And then add only the 'BelowCell' and the 'AboveCell' mappings.
When I run the app, I arrange the grid so that it looks like the following:
There is only one actual 'row' in the grid. It has 8 cells, but they are arranged, visually, into 2 rows and 4 columns. If I press 'Tab' when Col 7 is selected, Col 4 will be selected (it will wrap to the top of the next column). However, if I press shift-tab, while Col7 is selected, the selection will move 'up' to Col 3 as expected. If I press shift+tab again, Col 3 remains selected. I cannot navigate back to Col 8.
If I click on the 'Col 3' Columnname to the left of the actual cell - so that I exit edit mode, and then press the 'up' arrow on my keyboard, the grid selects 'Col 8' which is the behavior I want. I've added a keymapping to exiteditmode and then do 'AboveCell' but it still will not wrap for me.
If I add a handler for the Grid's BeforePerformAction Event and look at the UltraGridAction when I press the 'up' arrow (which is the behavior I want) it shows as 'AboveCell {19}'. When I am in edit mode and I press 'Shift+tab' the same break-point is hit and the UltraGridAction is the exact same 'AboveCell {19}' - but the cell will not wrap.
When I look at what the 'Tab' key is doing (since the tab key is working exactly how we want it to) I see the reverse. The UltraGridAction is 'BelowCell {20}'.
I could be wrong, but I'm wondering if this might be a bug?
I am using version 7.2.20072.61 of the UltraGrid.
Below is the code I used in my test app. Just create a new VB project, add the grid, and paste. If it's not a bug, maybe there is just something that I am missing?
-------------------------------------------------------------
Public Class Form1 Private Function CreateFakeDataTable() As System.Data.DataTable Dim data As New System.Data.DataTable data.Columns.Add("Col 1") data.Columns.Add("Col 2") data.Columns.Add("Col 3") data.Columns.Add("Col 4") data.Columns.Add("Col 5") data.Columns.Add("Col 6") data.Columns.Add("Col 7") data.Columns.Add("Col 8") data.Rows.Add(1, 2, 3, 4, 5, 6, 7, 8) Return data End Function Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'Set Grid formatting UltraGrid1.DisplayLayout.Bands(0).UseRowLayout = True UltraGrid1.DisplayLayout.Bands(0).RowLayoutLabelPosition = Infragistics.Win.UltraWinGrid.LabelPosition.Left UltraGrid1.DisplayLayout.Bands(0).RowLayoutLabelStyle = Infragistics.Win.UltraWinGrid.RowLayoutLabelStyle.WithCellData UltraGrid1.DisplayLayout.Override.AllowRowLayoutColMoving = Infragistics.Win.Layout.GridBagLayoutAllowMoving.AllowAll UltraGrid1.DisplayLayout.Override.AllowColMoving = Infragistics.Win.UltraWinGrid.AllowColMoving.WithinBand 'Remove the keymappings for 'tab' key For Each ugKey As Infragistics.Win.UltraWinGrid.GridKeyActionMapping In UltraGrid1.KeyActionMappings If ugKey.KeyCode = System.Windows.Forms.Keys.Tab Then UltraGrid1.KeyActionMappings.Remove(ugKey) End If Next 'Re-add keymappings for 'tab' key UltraGrid1.KeyActionMappings.Add(New Infragistics.Win.UltraWinGrid.GridKeyActionMapping(Windows.Forms.Keys.Tab, Infragistics.Win.UltraWinGrid.UltraGridAction.BelowCell, Nothing, Nothing, Infragistics.Win.SpecialKeys.All, Nothing)) UltraGrid1.KeyActionMappings.Add(New Infragistics.Win.UltraWinGrid.GridKeyActionMapping(Windows.Forms.Keys.Tab, Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, Nothing, Nothing, Infragistics.Win.SpecialKeys.All, Nothing)) 'Re-add keymappings for 'shift+tab' key UltraGrid1.KeyActionMappings.Add(New Infragistics.Win.UltraWinGrid.GridKeyActionMapping(Windows.Forms.Keys.Tab, Infragistics.Win.UltraWinGrid.UltraGridAction.AboveCell, Nothing, Nothing, Infragistics.Win.SpecialKeys.AltCtrl, Infragistics.Win.SpecialKeys.Shift)) UltraGrid1.KeyActionMappings.Add(New Infragistics.Win.UltraWinGrid.GridKeyActionMapping(Windows.Forms.Keys.Tab, Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, Nothing, Nothing, Infragistics.Win.SpecialKeys.AltCtrl, Infragistics.Win.SpecialKeys.Shift)) 'Set the data source UltraGrid1.DataSource = CreateFakeDataTable() End Sub Public Sub UltraGrid1_BeforePerformAction(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.BeforeUltraGridPerformActionEventArgs) Handles UltraGrid1.BeforePerformAction 'Set breakpoint to inspect e.UltraGridAction End SubEnd Class