Since Visual Studio 2008 is due out by the end of the Month I am updating some of my datagridview samples for LINQ.
To start off create a new windows forms application in VS 2008 make sure you select FrameWork 3.5 so you can use linq
I now added a new Linq to Sql designer to the project and named it Northwind. Drag the Northwind Products Table on to the design surface from the Server Explorer.
On your windows forms add a DataGridView (DataGridView1) and a NumericUpDown control (nuPage). For this example I will have the datagridview show 15 items at a time. In the form load event we will figure out how many pages there are and load the first 15 items into the datagridview. In the NumericUpdown controls value changed event we will update the data displayed
Public Class Form1
Dim bs As New BindingSource
Private intPages As Integer
Dim db As New NorthwindDataContext
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
intPages = Math.Ceiling(db.Products.Count / 15)
nuPage.Maximum = intPages
nuPage.Minimum = 1
Dim p = From prod In db.Products _
Select prod Skip 0 Take 15
bs.DataSource = p
bs.AllowNew = False
DataGridView1.DataSource = bs
End Sub
Private Sub nuPage_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles nuPage.ValueChanged
Dim p = From prod In db.Products _
Select prod Skip (nuPage.Value - 1) * 15 Take 15
bs.DataSource = p
End Sub
End Class