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

Programmatically Scrolling Grid

3 Answers 50 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jorge Gonzalez
Top achievements
Rank 1
Jorge Gonzalez asked on 29 Dec 2009, 10:52 PM
Hello,
   I was trying to figure out how to programmatically scroll the grid but the documentation on this site and on the Net did not help much. I finally figured it out. I have this code in the TextChanged event of a textbox so when the user types in some text this code is executed and the first line in the grid that contains the text in the textbox is scrolled too.

Here's my solution:

int numRows = gridname.Items.Count;

 for (int i = 0; i < numRows; i++)
    if (gridname.Items[i].ToString().Contains(<Text to look for goes in here>)
      {
         this.gridname.ScrollIntoView(gridname.Items[i]);
         break;
      }

My grid only contains 1 column.

3 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 30 Dec 2009, 12:59 PM
Hello Jorge Gonzalez,

You may also find the Search as You Type example appealing for your task. You can find it at http://demos.telerik.com/wpf/ -> GridView -> Filtering -> Search as You Type.

Best wishes,
Ross
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Jorge Gonzalez
Top achievements
Rank 1
answered on 30 Dec 2009, 02:49 PM
Thanks Ross,
    I actually downloaded this example or similar example from your site yesterday or the day before. It wasn't quite what I was looking for for I needed to do but I will use it latter on.
0
Jorge Gonzalez
Top achievements
Rank 1
answered on 04 Jan 2010, 07:11 PM
Hello,
    You can also do a search for text in the grid that begins with something using StartsWith:

int numRows = gridname.Items.Count;

 for (int i = 0; i < numRows; i++)
    if (gridname.Items[i].ToString().StartsWith(<Text to look for goes in here>)
      {
         this.gridname.ScrollIntoView(gridname.Items[i]);
         break;
      }

Tags
GridView
Asked by
Jorge Gonzalez
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Jorge Gonzalez
Top achievements
Rank 1
Share this question
or