C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » .NET Framework »

Scrolling DataGrid Programatically


Posted Date: 10 Feb 2007    Resource Type: Articles    Category: .NET Framework
Author: Pandian SMember Level: Gold    
Rating: 1 out of 5Points: 10



Scrolling DataGrid Programatically

'The DataGrid has a protected member named GridVScrolled that can be used to scroll the grid. We can derive from DataGrid and add a SendToRow method.

Steps :

'/** Add New Project --> Class Library --> MyDataGrid.vb (Name of Class Library)
'/** 'SendToRow' is a UserDefine Method.
'/** 'GridVScrolled' is a Protected Member.
'/*** Build --> Build Solution (DLL file created the Path. Ex: 'D:\WDataGrid\bin\WDataGrid.dll'.)

'/** 'System.Windows.Forms' Namespace for accessing the ScrollEventArgs Class, ScrollEventType Enum.


Imports System.Windows.Forms

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


'/** Open a New Windows Application and follow the below steps.
'/** Right Click on ToolBox --> (Select)Customize ToolBox --> (Select) .Net Framework Components (Tab)
'/** (Click) Browse (Button) --> Locate the File Path 'D:\WDataGrid\bin\WDataGrid.dll'.
'/** (Click) Open (Button) --> OK.
'/** Now, One New component added on your ToolBox named 'MyDataGrid'.
'/** You cane Drag and Drop it on your Form.

Imports System.Data.SqlClient

Public Class Form1
Inherits System.Windows.Forms.Form
Private _CON As SqlConnection
Private _ADA As SqlDataAdapter
Private _DSET As New DataSet()

Private Sub Form1_Load(...) Handles MyBase.Load
_CON = New SqlConnection("Server=;DataBase=;uid=;pwd=")
_ADA = New SqlDataAdapter("Select * from TableName", _CON)
_CON.Open()
_ADA.Fill(_DSET)
_CON.Close()
MyDataGrid1.DataSource = _DSET.Tables(0)
End Sub

Private Sub Button1_Click(...) Handles Button1.Click
MyDataGrid1.SendToRow(RowIndex)
MyDataGrid1.Select(RowIndex)
End Sub

'/** 'MyDataGrid1.SendToRow' send one value as 5, Grid scroll to 5th Row.
'/** The current row always @ first row.

'/** 'MyDataGrid1.Select' - Highlighted the row which you have given the 'RowIndex'.


Happy Coding




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Scrolling  .  Datagrid  .  Code  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Releasing COM Objects from Memory
Previous Resource: Evaluating String Expression - VB.Net
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use