Chapter 19 Quick Reference

Chapter 19 Quick Reference


Do this

Establish a connection to database tables in a project

Use the Data Source Configuration Wizard to link the project to a database, create a dataset, and fill the Data Sources window with a representation of the selected tables.

Create a data grid view object on a form to display an entire database table

Drag a table icon from the Data Sources window to the form. Then resize the data grid view object so that each column is visible.

Preview data bound to a data grid view object

Click the data grid view object's shortcut arrow to display the DataGridView Tasks list box. Click the Preview Data command, and then click the Preview button in the Preview Data dialog box.

Remove a column from a data grid view object

Click the data grid view object's shortcut arrow to display the DataGridView Tasks list box. Click the Edit Columns command, click the column that you want to remove in the Selected Columns list box, and then click the Remove button.

Sort the records in a grid at run time

Click the column header that you want to sort by. Visual Studio sorts the grid alphabetically based on that column.

Reverse the direction of a grid sort at run time

Click the column header a second time to reverse the direction of the sort (from A–Z to Z–A).

Change the default column width for a column in a data grid view object

In the Properties window, click the Columns property and then the ellipses button. In the Edit Columns dialog box, adjust the Width property.

Hide column headers in a data grid view object

Set the ColumnHeadersVisible property to False.

Create an alternating color scheme for rows within a data grid view object

Pick a color for alternating rows by using the AlternatingRowsDefaultCellStyle property. In the CellStyle Builder dialog box, adjust the BackColor property. The color that you select will alternate with white.

Change the color of gridlines in a grid

Adjust the GridColor property.

Add a second data grid view object to a form

Drag a second table from the Data Sources window to the form. Resize and customize the table, taking care to make the form large enough to display all the database columns and records that your user will want to see. If you want to add a second navigation bar to the form to provide access to the table, create a second BindingNavigator control on the form, and set its BindingSource property to the binding source representing the new table you created.

Prevent the user from editing or changing the data in a data grid view object

Set the grid's ReadOnly property to True.

Write changes made in the grid back to the underlying database

Verify that the data grid view object's ReadOnly property has been set to False. Then at run time, use the Save button on the navigation bar to save your changes and update the database. Alternatively, you can use the table adapter's Update method within program code.

Chapter 20

Creating Web Sites and Web Pages Using Microsoft Visual Web Developer and ASP.NET

After completing this chapter, you will be able to:

  • Start Visual Web Developer and create a new Web site.

  • Use Visual Web Developer tools and windows, including the Web Page Designer.

  • Use the Visual Web Developer Toolbox to add server controls to Web pages.

  • Add text, formatting effects, and Visual Basic code to a Web page that calculates loan payments for a car loan.

  • Create an HTML page that displays Help information.

  • Use the HyperLink control to link one Web page to another on a Web site.

  • Use the GridView control to display a table of database information on a Web page.

  • Set the Document object's Title property and assign a name to a Web page.

In this chapter, you'll learn how to build Web sites and Web pages by using the new Visual Web Developer tool included with Microsoft Visual Studio 2005. Visual Web Developer has the look and feel of the Visual Studio IDE, but it is customized for Web programming and Microsoft ASP.NET 2.0, the Microsoft .NET Framework component designed to provide state-of-the-art Internet functionality. ASP.NET was introduced with Microsoft Visual Studio .NET 2002 and is a replacement for WebClasses and the DHTML Page Designer in Microsoft Visual Basic 6. Although a complete description of Web programming and ASP.NET isn't possible here, there's enough in common between Web programming and Windows programming to allow you to do some useful experimentation—even if you have little or no experience with HTML. Invest a few hours in this chapter, and you'll see how quickly you can build a Web site that calculates loan payments for car loans, create an HTML page with Help information, and display loan prospects from an Access database by using the GridView control.

Upgrade Notes: Migrating Visual Basic 6 Code to Visual Basic 2005

If you're experienced with Visual Basic 6, you'll notice some new features in Visual Studio 2005, including the following:

  • A new Internet programming model called ASP.NET, and a new IDE called Visual Web Developer. These technologies are a replacement for the Visual Basic 6 WebClasses and DHTML Page Designer, which were discontinued in Visual Studio .NET 2002.

  • Although the Web Page Designer is distinct from the Windows Forms Designer, both IDE tools offer similar controls and support drag-and-drop programming techniques. Because the Web Page Designer is part of Visual Web Developer (a tool accessible to all Visual Studio programming languages), it's available to Microsoft Visual Basic 2005, Microsoft Visual C# 2005, and Microsoft Visual J# 2005.

  • Web sites and Web pages are designed to be displayed by Web browsers such as Microsoft Internet Explorer. The controls on Web pages are visible in the client's Web browser (in other words, on the end user's computer), but the functionality for the controls resides on the Web server that hosts the actual Web application.

  • Although many of the Web page controls have the same names as the Windows Forms controls, the controls aren't identical. For example, Web page controls have an ID property, rather than a Name property.