Can I have gridlines display in DataGridView even through I don't populate any data? If possible, how can I achieve it?
If you populate a datatable with spaces and use that as a datasource your gridview will have gridlines but appear to have no data.
Something like this:
Dim dt As New DataTable
'Column to hold row numbers
dt.Columns.Add(" ")
'Number of columns
For I = 1 To 5
dt.Columns.Add(I.ToString)
Next
'Number of rows
For I = 1 To 10
'Extra column holds the row number
dt.Rows.Add({I.ToString," ", " ", " ", " ", " "})
Next
SalesDGV.DataSource = dt
how do I insert it so that the gridlines is still there and that the data is insert in row accordingly?
put the data into the datatable. Just check for null data and make it a space instead. If you're adding the data from a database, one way is to loop through the columns and rows of the datatable looking for empty data and changing it to a space. If the data is from a file you probably already have a loop that you can use to modify the data.