How to Add Columns to the DBGrid Control at Design Time

Last reviewed: May 16, 1996
Article ID: Q141897
The information in this article applies to:
  • Standard, Professional, and Enterprise Editions of Microsoft Visual Basic, 16-bit and 32-bit, for Windows, version 4.0

SUMMARY

This article shows how to add columns to the DBGrid control at design time. Adding columns is accomplished by setting properties of the Column objects by using the right mouse button to click on the control.

MORE INFORMATION

Use of the right mouse button (right click) to click on the DBGrid control is not clearly documented in online help; however, it is discussed briefly in Chapter 24 of the Programmer's Guide in the Design-time Operations section and in more detail in Books Online.

Step-by-Step Example

  1. Start Visual Basic or on the File menu, click New Project (ALT, F, N) if Visual Basic is already running. Form1 is created by default.

  2. On the Tools menu, click Custom Controls, then check the DataBound grid control.

  3. Click OK; this adds the control icon to the toolbar.

  4. Add one DBGrid control to the form1.

  5. Right-click the control and click Edit on the menu.

  6. Right-click the control again and click Insert or Append.

Clicking Insert inserts a new column to the left of the selected column(s) or to the left of the column under the cursor.

Clicking Append adds a new column to the far right of the columns in the control.

The result is that one additional column is added.

REFERENCES

Visual Basic Books Online.


Additional reference words: 4.00 vb4win vb4all
KBCategory: kbusage
KBSubcategory: PrgCtrlsCus



THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: May 16, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.