README.md
December 5, 2022 ยท View on GitHub
Description
The purpose of the code is to show how to add columns to a VB.NET DataGrid control.
More Info
Add a datagrid control to your form. called DataGrid1
Double click on your form and replace the Form1_Load() function with the code...
| Submitted On | |
| By | Johan Strydom |
| Level | Beginner |
| User Rating | 4.8 (19 globes from 4 users) |
| Compatibility | VB.NET |
| Category | Controls/ Forms/ Dialogs/ Menus |
| World | .Net (C#, VB.net) |
| Archive File |
Source Code
'You can't have a data grid column without a DataTable ... I think :)
Private dbTable As New DataTable("DTBL1")
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i = 0
'Add 4 columns to the table
For i = 1 To 4
dbTable.Columns.Add("Col" & i)
Next
'Set the datasource to our database table
DataGrid1.DataSource = dbTable
End Sub