Solved

simulate scroll for datagrid

Posted on 2006-11-14
3
242 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
ID: 17944846
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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
EF5: Question about Metadata Artifact Processing 4 23
SQL LINE CONTINUATION ISSUE 12 38
start a process from a service 3 33
ASP/VB email question 4 46
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

828 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