Visual Studio 2005 Using the DataGridView Control

19
Visual Studio 2005 Using the DataGridView Control V. Matos Cleveland State University

description

Visual Studio 2005 Using the DataGridView Control. V. Matos Cleveland State University. Create Windows Project: WinDB_Demo_01. Main menu: Data | Add New Data source …. Select: Database and click on Next. Select existing DB connection (or create a new one). - PowerPoint PPT Presentation

Transcript of Visual Studio 2005 Using the DataGridView Control

Visual Studio 2005

Using the DataGridView Control

V. Matos

Cleveland State University

2

Create Windows Project: WinDB_Demo_01

3

Main menu: Data | Add New Data source …

4

Select: Database and click on Next

5

Select existing DB connection (or create a new one)

6

Save selected connection string

7

Choose Database Objects

8

You may choose a specific table (instead of ALL of them)

9

VB project now contains a local DataSet reflecting the image of selected database objects

10

From VB Toolbox drag to the form a DataGridView control

11

Choose Data Source from the current Project’s DataSet selection

12

After choosing: Department

13

Add a BindingNavigator control to allow motion and maintenace on the DataView

14

Modify the BindingNavigatorInsert Standard Items

15

After adding Standard Itemsclick/delete unwanted icons

16

Click on the BindingNavigator control. Modify its Property page (Associate the DEPARTMENTBindingSource with the BindingNavigator)

17

Final image of the DataView and its corresponding ToolStrip

18

Double-click on the SAVE icon and insert the following VB code

Private Sub SaveToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripButton.Click

Me.Validate()

If (Me.CompanyDataSet.HasChanges) Then

Me.DEPARTMENTBindingSource.EndEdit()

Me.DEPARTMENTTableAdapter.Update(Me.CompanyDataSet.DEPARTMENT)

End If

End Sub

19

Finally…