Click Here to Install Silverlight*
United StatesChange|All Microsoft Sites
Microsoft
Download Center 
Search Advanced Search

Visual Basic .NET Code Sample: DataGrid Formatting

Brief Description
This sample shows how you can retrieve data from the database, display the data in a DataGrid, and how to format the appearance of the DataGrid.

On This Page

Quick Details
File Name:DataGridFormatting.exe
Version:1.0
Date Published:7/29/2002
Language:English
Download Size:175 KB
Estimated Download Time: 1 min 56K

Overview

This sample shows how you can retrieve data from the database, display the data in a DataGrid, and how to format the appearance of the DataGrid.

 Top of page

System Requirements

  • Supported Operating Systems: Windows 2000; Windows NT; Windows XP
- Microsoft Visual Studio. NET Professional
- Access to the Northwind database residing in SQL Server or the Microsoft Data Engine (MSDE)

 Top of page

Instructions

- Select "Run this Program from its Current Location" to start the download immediately.
- Select "Save this Program to Disk" to copy the download to your machine for installation at a later time.


To install MSDE, do the following:

  1. Open the Start menu, then click Programs, then click
    Microsoft .NET Framework SDK, and then click Samples and Quickstart Tutorials.

  2. Click "Step 1: Install the .NET Framework Samples Database".
  3. Open a command window, and CD to \Samples\Setup. This is typically: C:\Program Files\Microsoft Visual Studio .NET\FrameworkSDK\Samples\Setup

  4. Type: osql -E -S (local)\NetSDK -i InstNwnd.sql

 Top of page

Additional Information

Featured Highlights ADO.NET is used to retrieve the information from SQL Server. The data is loaded into a DataSet, and the DataGrid is populated by binding to the DataSet. The controls on this form utilize anchoring so that the form resizes intelligently without the developer having to write any code. Formatting the DataGrid's appearance is accomplished using code in four button click event handlers. The formatting code implemented in each event handler increases in complexity and granularity. The buttons are named as follows (ranked in order of increasing control over formatting):
  1. Default: Only default DataGrid formatting is used.
  2. Grid Properties: Only DataGrid formatting properties are used.
  3. Table Style: A DataGridTableStyle object is used to format the DataGrid.
  4. Column Styles: DataGridColumnStyle objects are added to the DataGridTableStyle object.

 Top of page

What Others Are Downloading

Others who downloaded Visual Basic .NET Code Sample: DataGrid Formatting also downloaded:
  1. Visual Basic .NET Code Sample: Data Access - Data Entry Form
  2. Visual Basic .NET Code Samples: Master Set of 101 Samples

 Top of page


© 2009 Microsoft Corporation. All rights reserved. Contact Us |Terms of Use |Trademarks |Privacy Statement