Solved

simulate scroll for datagrid

Posted on 2006-11-14
3
240 Views
Last Modified: 2010-05-18
Hi, i have a datagrid...how could i make it in such a way that when i click on a button it will scroll down or up?

thanks
0
Comment
Question by:jaxrpc
3 Comments
 
LVL 16

Accepted Solution

by:
Hillwaaa earned 500 total points
Comment Utility
Hi jaxrpc,


I found this at (http://www.windowsforms.net/FAQs/default.aspx?PageID=2&ItemID=538&CategoryID=3&tabindex=3).  You should be able to use this to create a custom scrollable datagrid, just keep an integer in your form that keeps track of the current row.

Dim currentRow as integer = 0

'This is the scroll down button code
Private Sub downButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles downButton.Click
    currentRow += 1
    Me.yourDataGrid.ScrollToRow(currentRow)
End Sub



How do I programmatically scroll a DataGrid to a particular row?      

The DataGrid has a protected GridVScrolled member that can be used to scroll the grid. To use it, you can derive from DataGrid and add a ScrollToRow method. Here is a code snippet.

Public Class MyDataGrid
    Inherits DataGrid
  Sub ScrollToRow(ByVal row As Integer)
    If Not Me.DataSource Is Nothing Then
      GridVScrolled(Me, New ScrollEventArgs(ScrollEventType.LargeIncrement, row))
    End If
  End Sub
End Class

Daniel Herling, Microsoft

Cheers,
Hillwaaa
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Text in tooltip bound field bridview 3 29
Total in textboxes 9 33
Library to convert HTML to PDF. 8 41
Copy/Clone an object. 9 7
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now