Start out DataGrid with blank columns

  • Thread starter Thread starter tshad
  • Start date Start date
T

tshad

I have a DataGrid in VS 2003 that I am setting up and am binding a dataset
to it that I am creating from a Directory file list.

Since there are no columns before the program starts, it shows as a grey box
with a blue title bar.

I tried to set the tableStyles at the start of the program hoping it would
show the columns as blank, but that didn't work.

Is there some way to set it up to show columns (and get rid of the title Bar
as well)?

Here is how I have the TableStyles set.

***********************************************
Dim gtStyle As New DataGridTableStyle
gtStyle.MappingName = "FileListTable"
gtStyle.AlternatingBackColor = Color.LightBlue

'
' Create GridColumnStyle objects for the grid columns
'
Dim colStyle1 As New DataGridTextBoxColumn
Dim colStyle2 As New DataGridTextBoxColumn
Dim colStyle3 As New DataGridTextBoxColumn

'
' Set column 1's caption, width and disable editing.
'
With colStyle1
.MappingName = "FileName"
.HeaderText = "File name"
.Width = 300
.Alignment = HorizontalAlignment.Left
.TextBox.Enabled = False
End With

'
' Set column 2's caption, width and disable editing.
'
With colStyle2
.MappingName = "Length"
.HeaderText = "Length"
.Width = 100
.Alignment = HorizontalAlignment.Left
.TextBox.Enabled = True
End With

'
' Set column 3's caption, width and disable editing.
'
With colStyle3
.MappingName = "DateModified"
.HeaderText = "Date Modified"
.Width = 100
.Alignment = HorizontalAlignment.Left
.TextBox.Enabled = True
.Format = "yyyy-MM-dd"
End With


' Add the GridColumnStyles to the DataGrid's Column Styles collection.
'
With gtStyle.GridColumnStyles
.Add(colStyle1)
.Add(colStyle2)
.Add(colStyle3)
End With

'
' Add the GridTableStyle to the DataGrid
'
DataGrid1.TableStyles.Add(gtStyle)
***********************************************

Thanks,

Tom
 
I have a DataGrid in VS 2003 that I am setting up and am binding a dataset
to it that I am creating from a Directory file list.

Since there are no columns before the program starts, it shows as a grey box
with a blue title bar.

I tried to set the tableStyles at the start of the program hoping it would
show the columns as blank, but that didn't work.

Is there some way to set it up to show columns (and get rid of the title Bar
as well)?

Here is how I have the TableStyles set.

***********************************************
Dim gtStyle As New DataGridTableStyle
gtStyle.MappingName = "FileListTable"
gtStyle.AlternatingBackColor = Color.LightBlue

'
' Create GridColumnStyle objects for the grid columns
'
Dim colStyle1 As New DataGridTextBoxColumn
Dim colStyle2 As New DataGridTextBoxColumn
Dim colStyle3 As New DataGridTextBoxColumn

'
' Set column 1's caption, width and disable editing.
'
With colStyle1
.MappingName = "FileName"
.HeaderText = "File name"
.Width = 300
.Alignment = HorizontalAlignment.Left
.TextBox.Enabled = False
End With

'
' Set column 2's caption, width and disable editing.
'
With colStyle2
.MappingName = "Length"
.HeaderText = "Length"
.Width = 100
.Alignment = HorizontalAlignment.Left
.TextBox.Enabled = True
End With

'
' Set column 3's caption, width and disable editing.
'
With colStyle3
.MappingName = "DateModified"
.HeaderText = "Date Modified"
.Width = 100
.Alignment = HorizontalAlignment.Left
.TextBox.Enabled = True
.Format = "yyyy-MM-dd"
End With

' Add the GridColumnStyles to the DataGrid's Column Styles collection.
'
With gtStyle.GridColumnStyles
.Add(colStyle1)
.Add(colStyle2)
.Add(colStyle3)
End With

'
' Add the GridTableStyle to the DataGrid
'
DataGrid1.TableStyles.Add(gtStyle)
***********************************************

Thanks,

Tom

Hmmm, well you could try to call the dataadapter.FillSchema method on
your query. This will give you an empty dataset, but with all of the
column information in it. You can then bind to the empty dataset -
once your ready, you can change it to your filled dataset.
 
Back
Top