This is a migrated thread and some comments may be shown as answers.

How to avoid the keyboard Tab press event selects the GridViewSelectColumn checkbox

1 Answer 29 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Gopinath
Top achievements
Rank 2
Gopinath asked on 11 Dec 2012, 02:04 PM
HI,

I have a GridViewSelectColumn  in my Gridview.

As per my requirement when tab key is pressed , next row should be selected and when the shift+tab is pressed previous row should be selected.

But in my case when the Gridview loads first time , by default first row's check box is selected. Afterwards if i press tab, next row's checkbox is getting selected.

But i dont want check box to be selected neither at loading time not at TAB key press event.

Can anyone suggest the way please.

Below is my sample code

public void PdgSearchWidget_KeyDown(object sender, KeyEventArgs e)
        {
            int getRow = -1;
            if (PdgSearchGrid.SelectedItem != null)
            {
                getRow = PdgSearchGrid.Items.IndexOf(PdgSearchGrid.SelectedItem);
            }

            if (e.Key == Key.Tab && (Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
            {
                if (getRow > 0)
                {
                    getRow--;
                }
            }
            else if (e.Key == Key.Tab)
            {
                if (getRow < PdgSearchGrid.Items.Count)
                {
                    getRow++;
                }
            }

            if (getRow != -1)
            {
                PdgSearchGrid.SelectedItem = PdgSearchGrid.Items[getRow];
              
                this.Dispatcher.BeginInvoke(new Action(() =>
                {
                    this.PdgSearchGrid.CurrentCellInfo = new GridViewCellInfo(this.PdgSearchGrid.SelectedItem, this.PdgSearchGrid.Columns[0]);
                    if (this.PdgSearchGrid.CurrentCell != null)
                        this.PdgSearchGrid.CurrentCell.Focus();

                }));
                this.PdgSearchGrid.ScrollIntoView(this.PdgSearchGrid.SelectedItem);
                this.PdgSearchGrid.Focus();
            }
        }

Thanks
Gopinath

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 11 Dec 2012, 03:22 PM
Hello,

I have answered to your other forum thread.

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Gopinath
Top achievements
Rank 2
Answers by
Dimitrina
Telerik team
Share this question
or