How to Change the DataGrid Color in VB6

Written by lora covrett
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Change the DataGrid Color in VB6
A datagrid displays information similar to an Excel spreadsheet. (Medioimages/Photodisc/Photodisc/Getty Images)

Users like to see data in an organised and easily accessible format. The Microsoft DataGrid control does just that. It is a control that displays data in a column and row format, much like an Excel spreadsheet. Data exists in the database table in columns and rows as well; therefore the DataGrid makes it easy for users to view and edit the data. The DataGrid control has properties that can be set at design-time or run-time. Design-time settings are displayed when the user first sees the screen. Changes made during run-time happen instantly, while the user is working within the application.

Skill level:
Moderately Challenging


  1. 1

    Add the DataGrid to your VB project by selecting "Project" and then "Components."

  2. 2

    Select "Microsoft DataGrid Control 6.0 (OLEDB)" from the list of available components and click the "OK" button to save your changes and close the screen. The DataGrid will now be in your toolbox.

  3. 3

    Select the DataGrid control from the toolbox, and drop it onto your VB form. The DataGrid will look similar to a database table or an Excel spreadsheet.

  4. 4

    Set the properties for how you want the control to look now. This is how the user will see the data when they first see the DataGrid.

  5. 5

    Change the background colour of the DataGrid when the user clicks on it by coding "DataGrid1.BackColor = vbNewColor" in the "DataGrid1_Click()" subroutine where "DataGrid1" is the name of the control on the form and "vbNewColor" is the new background colour. The background colour changes for the entire control and "DataGrid1.Refresh" will make it instantly visible to the user.

  6. 6

    Change the text colour of the DataGrid when the data changes by coding "DataGrid1.ForeColor = vbNewColor" in the "DataGrid1_RowColChange()" subroutine. The code executes after a value within the DataGrid is changed and loses focus. The text for the entire contents of the DataGrid will be changed to "vbNewColor" after "DataGrid1.Refresh."

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.