0
votes

When we press the TAB key we change the focus to the next control in the given tab order. In my case when I click on a check box (say X) then after pressing Tab button the control is going on a text field instead of going on next check box (say Y) which was previously disabled and became enabled after the tab button was pressed. I want the control to move to the Check box Y. Thanks.

I have following code but it is not running when I'm pressing Tab Button:

        if (((e.KeyCode == Keys.Tab && !e.Shift) || e.KeyCode == Keys.Enter)  && _resultsGrid.ActiveCell != null)
        {
            if (_resultsGrid.ActiveCell.IsInEditMode && (_resultsGrid.ActiveCell == lastEditableCell || e.KeyCode == Keys.Enter))
            {
                DateTime tempDateTime = DateTime.Today;
                if (!(_resultsGrid.ActiveCell.Column.DataType.ToString() == "System.DateTime" && !System.DateTime.TryParse(_resultsGrid.ActiveCell.Text, out tempDateTime)))
                {
                    if (_resultsGrid.ActiveCell.Text == "" && (_resultsGrid.ActiveCell.Column.DataType == typeof(System.Int16) || 
                        _resultsGrid.ActiveCell.Column.DataType == typeof(System.Int32) ||
                        _resultsGrid.ActiveCell.Column.DataType == typeof(System.Int64) ||
                        _resultsGrid.ActiveCell.Column.DataType == typeof(System.Decimal)))
                        _resultsGrid.ActiveCell.Value = 0;
                    else
                        _resultsGrid.ActiveCell.Value = _resultsGrid.ActiveCell.Text;
                }
                _returnKeyClickedToSaveRow = true;
                FireSaveEvent();
                if (!_saveFailed)
                {
                    if (e.KeyCode == Keys.Tab)
                    {
                        _checklastkey = true;
                        _resultsGrid.PerformAction(UltraGridAction.CommitRow);
                    }
                    else
                    {
                        _resultsGrid.PerformAction(UltraGridAction.CommitRow);
                        _resultsGrid.PerformAction(UltraGridAction.DeactivateCell);
                    }
                }
                _returnKeyClickedToSaveRow = false;
                this._entityDS.AcceptChanges(); //EAMNET-9811
            }
        }
1
Change the tab order of Checkbox Y to come after X? It will be skipped as long as it is disabled.GolezTrol
It sounds like you're using the wrong event to decide to enable check box Y - if check box X enables check-box Y, it should probably be doing it in its checked event - it sounds like you're doing it in something like a blur/leave event, at which point the next control to move to has already been decided upon.Damien_The_Unbeliever

1 Answers

0
votes

There is a property each control has which is called TabIndex. You can assign the next control which gets focused on TAB key using this property. For example If Control1 has TabIndex 1 and Control2 has TabIndex 2, after pressing TAB key on Control1, Control2 would be focused.

P.S. As TabIndex is a property in each Control, You can also dynamically decide on next control to get focused wherever you want by changing TabIndex's.