This question is locked. New answers and comments are not allowed.
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
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