scroll to data with keyboard letters like ListBox

Oct 30, 2009 at 11:52 PM

Is there an easy way to have the data grid handle letter keystrokes to scroll to data in the datagrid?  ie, if they press L, it would scroll to rows with the first column's data starting with L.  If so, is there a way to specify which columns it will look for?




Nov 21, 2009 at 12:27 AM

Hi Dan,

The only way I can quickly think to do this, is to do it in the keypress event, then run through the list to find the index of the item that StartsWith and scroll that item into view. I am assuming you use a generic list for the ItemsSource?

private void DGKeyPressed(object sender, KeyEventArgs e){
  DataGrid dg = sender as DataGrid;
  foreach(obj in dg.Items){

Havent tried it, but it should work