SunQuest
 
       Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 4 - Using Data Sources with the DataGridView C...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
Moblin 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC.NET

Using Data Sources with the DataGridView Control
By: Murach Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 7
    2006-11-09

    Table of Contents:
  • Using Data Sources with the DataGridView Control
  • How to generate a DataGridView control from a data source
  • How to edit the properties of a DataGridView control
  • How to edit the columns of a DataGridView control
  • A Product Maintenance application that uses a DataGridView control

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Using Data Sources with the DataGridView Control - How to edit the columns of a DataGridView control


    (Page 4 of 5 )

     

    Figure 14-8 shows how to edit the columns of a DataGridView control using the Edit Columns dialog box. From this dialog box, you can remove columns from the grid by selecting the column and clicking the Remove button. You can also change the order of the columns by selecting the column you want to move and clicking the up or down arrow to the right of the list of columns.

    Finally, you can use the Add button in this dialog box to add a column to the grid. You might need to do that if you delete a column and then decide you want to include it. You can also use the dialog box that’s displayed when you click the Add button to add unbound columns to the grid. You’ll learn how to do that in the next chapter.

    Once you’ve got the right columns displayed in the correct order, you can edit the properties for a column by selecting the column to display its properties in the Bound Column Properties window. When you see the Product Maintenance form in the next figure, for example, you’ll see that I changed the HeaderText property for the ProductCode and UnitPrice columns to provide shorter names for the column headers. In addition, I changed the Width property of each column as appropriate. Finally, I used the DefaultCellStyle property to apply currency formatting to the UnitPrice column.

    The dialog box for editing the columns of a DataGridView control

    Common properties of a column

    Property

    Description

    HeaderText

    The text that’s displayed in the column header.

    Width

    The number of pixels that are used for the width of the column.

    DefaultCellStyle

    The style that’s applied to the cell. You can use dialog boxes to set style elements such as color, format, and alignment.

    Description

    • You can use the Edit Columns dialog box to control which columns are displayed in the grid and to edit the properties of those columns. To display this dialog box, choose the Edit Columns command from the smart tag menu for the control
    • To remove columns from the grid, select the column and click the Remove button.
    • To add a column to the grid, click the Add button and then complete the dialog box that’s displayed. This dialog box lets you add both bound and unbound columns. See chapter 15 for more information on adding unbound columns.
    • To change the order of the columns, select the column you want to move and click the up or down arrow to the right of the list of columns.
    • To edit the properties for a column, select the column and use the Bound Column Properties window to edit the properties.

    Figure 14-8.   How to edit the columns of a DataGridView control

    More Visual Basic.NET Articles
    More By Murach Publishing


       · This article is an excerpt from the book "Murach's Visual Basic 2005," published by...
     

    Buy this book now. This article is excerpted from chapter 14 of the book Murach's Visual Basic 2005, written by Anne Boehm (Murach, 2006; ISBN: 1890774383). Check it out today at your favorite bookstore. Buy this book now.

    VISUAL BASIC.NET ARTICLES

    - Movement and Player Statistics in a VB.NET T...
    - Creating and Drawing a Game Map in VB.NET
    - Working with Classes and Properties for Game...
    - Working with Loops, Arrays, and Collections ...
    - Learning Loops in VB.NET for Game Development
    - Learning VB.NET: Working with Variables, Con...
    - The Basics of VB.NET Through Text Game Devel...
    - Learning VB.NET Through Text Game Development
    - Types of Operators in Visual Basic
    - Operators
    - Understanding Custom Events using Visual Bas...
    - Polymorphism using Abstract Classes in Visua...
    - Shadowing using Shadows in Visual Basic.NET ...
    - Overloading and Overriding in Visual Basic.N...
    - More on Controlling Windows Fax Services Usi...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway