We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Enter/Tab to next row

Is there a simple way to enable the TAB and/or ENTER key to wrap around from the last column of the current row to the first column of the next row? And vice versa?

17 Replies

AD Administrator Syncfusion Team February 14, 2003 03:41 PM UTC

Try Grid.Model.Options.WrapCellBehavior = = GridWrapCellBehavior.WrapRow; or Grid.Model.Options.WrapCell = true; Stefan


BO Bruce Onder February 14, 2003 03:59 PM UTC

Wow, what a terrific object model -- I was presuming I'd have to trap a cell change event, see if I was on the last column and moving "right" and then increment the row, etc. But noooo -- set a property and you're ready to rock! :) Thanks! --Bruce


BO Bruce Onder February 17, 2003 03:12 AM UTC

Hmm. the behavior seems to work if I'm not doing anything special, but if I try to apply conditional enable/disable on columns in the PrepareViewStylesInfo event, the wrapbehavior seems to be overridden in some way. Here's some sample code. The commented code seems to prevent the wrap behavior: Private Sub grdLineItems_PrepareViewStyleInfo(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs) Handles grdLineItems.PrepareViewStyleInfo Dim iColIndex As OrderItemColumns = CType(e.ColIndex, OrderItemColumns) If (e.RowIndex > grdLineItems.Model.Rows.HeaderCount) Then Select Case iColIndex Case OrderItemColumns.LineSequenceNumber If (e.Style.CellType = "Image") AndAlso (e.RowIndex < grdLineItems.Model.RowCount) Then e.Style.ImageIndex = GetImageIndex(e.RowIndex - 1) End If 'Case OrderItemColumns.CaseQuantityOrdered ' Dim bEnabled As Boolean = (Not grdLineItems.Item(e.RowIndex, OrderItemColumns.ProductNumber).Text = "") ' e.Style.Enabled = bEnabled ' e.Style.BackColor = CType(IIf(bEnabled, m_EnabledBackColor, m_DisabledBackColor), Color) 'Case OrderItemColumns.EachQuantityOrdered ' Dim bEnabled As Boolean = (Not grdLineItems.Item(e.RowIndex, OrderItemColumns.ProductNumber).Text = "") ' Dim txtValue As String = grdLineItems.Item(e.RowIndex, OrderItemColumns.WillBreakFlag).Text ' bEnabled = bEnabled AndAlso (txtValue.ToLower() = "true") ' e.Style.Enabled = bEnabled ' e.Style.BackColor = CType(IIf(bEnabled, m_EnabledBackColor, m_DisabledBackColor), Color) End Select End If End Sub The commented-out column checks are the last two columns displayed in my grid. If I apply a global enabled=false to the EachQuantityOrdered column (the rightmost column), then the CaseQuantityOrdered column (second rightmost) then correctly controls the wrap behavior. However, if I apply the conditional code in PrepareViewStyleInfo, then even when the EachQuantityOrdered column is enabled, the wrap behavior does not work (WrapRow). Any thoughts on this? --Bruce


AD Administrator Syncfusion Team February 17, 2003 09:26 AM UTC

The PrepareViewStyleInfo event should only be used for setting style properties used in the drawing of the cell. This event is fired only immediately before the cell is drawn. If you need to dynamically set a style property that needs to be passed to other events such as moving the current cell code, then you should handle the QueryCellInfo event and set the style there. QueryCellInfo is the event that is fired anytime the style is required (not just when the cell is drawn).


AD Administrator Syncfusion Team February 17, 2003 09:49 AM UTC

Actually, the PrepareViewStyleInfo should be fine for this scenario. But I remember we fixed some issues with WrapCell in the latest patches. We will update also the eval later this week to version 1.5.1.6 and you should give it a try then. If you continue to have problems, just send a small sample project. Stefan


BO Bruce Onder February 17, 2003 02:04 PM UTC

Will this be available as a patch, or as a full new eval download?


AD Administrator Syncfusion Team February 17, 2003 04:30 PM UTC

The eval will only be available as full download, not patch. Stefan


JG James Gramosli NO LONGER WITH COMPANY December 20, 2007 05:21 PM UTC

Whats the latest with this option? I'm using Essential Studio 5.2.0.25 and it doesnt seem to work in that version.

How can I allow tabs to run through the grid rows?



AD Administrator Syncfusion Team December 21, 2007 10:20 AM UTC

This gridControl1.Model.Options.WrapCellBehavior = GridWrapCellBehavior.WrapRow property should work OK in a GridControl or a GridDataBoundGrid for most situations. The only situation that we know about where this property does not work as expected is when the last column has disabled cells. In such a case, you would then have to handle the QueryNextCurrentCellPosition which allows you to control exactly how the tabbing works.




WindowsApplication1.zip


JG James Gramosli NO LONGER WITH COMPANY December 21, 2007 01:16 PM UTC

We are using the Syncfusion.Windows.Forms.Grid.Grouping.GridGroupingControl in hierarchy mode with a DataSet and Relationships.

The last column is an unbound column which is a push button, it is set to readonly but not to Enabled=false. Should it still work for us?



AD Administrator Syncfusion Team December 24, 2007 07:31 PM UTC

There is no property setting that will control tabbing to the next record in the setup you described.

The reason is that the next row in the grid may be a summary row or a nested child table or something else (ie, the grid does not just hold simple records). You would have to catch the tab key and manage moving the current cell according to how you want things to work in this situation. For exampe, if your user tabs into a collapsed child table, it it automatically expand, or should the child table be skipped and the next visible record made current (skipping any summary, footnotes, etc)? In this case, to catch the tab key, you can handle the TableControlCurrentCellKeyDown event.



SI singh May 26, 2018 07:19 AM UTC

This is working fine.If we press enter focus moves to next column and in last column on pressing enter focus moves to next row first column.
If we want to skip readonly columns .

Col1                          Col2                    Col3
Readonly False     Readonly True      ReadonlyFalse

On Pressing enter from col1 focus should be on col3.

And if Col 3 readonly also true then foucs should be in next row, first cell.

Thanks & Regards


SN Sindhu Nagarajan Syncfusion Team May 28, 2018 12:59 PM UTC

Hi Raman, 

Thanks for contacting Syncfusion support. 

We are able to understand your scenario. We have prepared a simple sample as per your requirement. In the sample, customizations are done in the KeyDown event. Current cell is set to the column next to the Read-Only column by using CurrentCell.MoveTo()  method. Please refer to the below code and sample, 
 
Code Example 
//Event Subscription 
gridControl1.KeyDown += GridControl1_KeyDown; 
 
//Event Handling 
private void GridControl1_KeyDown(object sender, KeyEventArgs e) 
{ 
    if (e.Modifiers == Keys.None && e.KeyCode == Keys.Tab) 
    { 
        var cc = gridControl1.CurrentCell;               
        while (gridControl1[cc.RowIndex,cc.ColIndex + 1].ReadOnly) 
        { 
            //To increment rowIndex when last column is made as Read-Only 
            if (cc.ColIndex+1 >= gridControl1.ColCount) 
            { 
                cc.MoveTo(cc.RowIndex + 1, 0); 
            } 
            else 
                cc.MoveTo(cc.RowIndex, cc.ColIndex + 1); 
        } 
    }            
} 


Please let us know if you have any other queries. 

Regards, 
Sindhu  



LH Lenny H February 10, 2020 11:47 PM UTC

When I try to MoveTo() a cell that is read only the expression returns false and nothing happens. The code created by Sindhu becomes an infinite loop!!!


AR Arulpriya Ramalingam Syncfusion Team February 11, 2020 07:15 AM UTC

Hi Lenny, 
 
Thank you for using Syncfusion product. 
 
By default, the CurrentCell will be moved to next cell of the grid when the TAB/ENTER key is pressed. The previous solution is provided to skip the ReadOnly cells activation when the tab/enter key pressed. It moves the current cell to next editable cell to update the cell value and to reach the editable cell with optimized actions. If you need to move the current cell to next cell for all the cells, the customization need not to be implemented at your end since, the GridControl have the built-in behavior to move next cell. 
 
Please get back to us with a simple screenshot of your exact requirement, if we misunderstood the scenario. 
 
Arulpriya 



LH Lenny H February 11, 2020 01:27 PM UTC

I created a workaround with a dictionary that puts the cursor exactly where we want after a tab.
It maps current position to next position for our exceptions and read only cells.
We have a few special cases that we need to modify.

 
I've found that some of our headers span multiple rows for padding, some are not marked read only (they don't have any input capabilities) and that may have caused the problem. For some reason that causes MoveTo() to become FALSE and the loop becomes infinite. You can check that behavior.






AR Arulpriya Ramalingam Syncfusion Team February 12, 2020 07:00 AM UTC

Hi Lenny, 
 
Thank you for the update. 
 
We have tested the scenario by adding multiple header rows with spanned cells. By default, the next cell is moved properly regardless of readonly and celltype. So, we suspect that the use case might be occurred due the customization that you have handled at your end for CurrentCellMoving action. So, please refer the below sample and let us know that code part that causes the issue at your end which will be helpful for us to assist you further. 
 
 
Also, confirm us that whether you have handled the event CurrentCellMoving for any particular cases. If yes, share those use cases with code snippet. 
 
Arulpriya 


Loader.
Live Chat Icon For mobile
Up arrow icon