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
Add the DataGrid to your VB project by selecting "Project" and then "Components."
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.
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.
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.
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.
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."
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for