How to Add Columns to the DBGrid Control at Design Time (141897)



The information in this article applies to:

  • Microsoft Visual Basic Standard Edition, 32-bit, for Windows 4.0
  • Microsoft Visual Basic Professional Edition, 16-bit, for Windows 4.0
  • Microsoft Visual Basic Professional Edition, 32-bit, for Windows 4.0
  • Microsoft Visual Basic Enterprise Edition, 16-bit, for Windows 4.0
  • Microsoft Visual Basic Enterprise Edition, 32-bit, for Windows 4.0

This article was previously published under Q141897

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.

Modification Type:MajorLast Reviewed:12/9/2003
Keywords:KB141897