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

2 posts, 0 answers
  1. Gopinath
    Gopinath avatar
    63 posts
    Member since:
    Sep 2011

    Posted 11 Dec 2012 Link to this post

    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
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 11 Dec 2012 Link to this post

    Hello,

    I have answered to your other forum thread.

    Greetings,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
Back to Top