column

  • Thread starter Thread starter Steiner Hubert
  • Start date Start date
S

Steiner Hubert

hello,
how can i add a column in the datagrid?

i use in basic (pocket pc):
toGrid.DataSource = dset.Tables("myTable")

but in the grid is _one_ column visible
 
This is, probably, because "myTable" has only one column:- what value
has dset.Tables("myTable").Columns.Count?

The other reason could be because you set only one column in the
DataGridTableStyle.
 
Unless you specify a specific style for the datagrid control it will show
all of the columns in the datasource it's bound to. So adding a column to
your datatable will show it in the grid.

Peter
 
Have you set up a custom DataGridTableStyle? if so you must specify every
column you wish to display, not just those you wish to modify from their
defaults.

Peter
 
i try:
toGrid.DataSource = dset.Tables("Mittel")
Dim TableStyle As New DataGridTableStyle
Dim DictionrGridColumns As GridColumnStylesCollection =
TableStyle.GridColumnStyles
With DictionrGridColumns
..Add(New DataGridTextBoxColumn)
With .Item(0)
..MappingName = "name"
..HeaderText = "Name"
..Width = 40
End With
..Add(New DataGridTextBoxColumn)
With .Item(1)
..MappingName = "id"
..HeaderText = "ID"
..Width = 60
End With
..Add(New DataGridTextBoxColumn)
' Define Dictionary Grid Columns Styles
toGrid.TableStyles.Add(TableStyle)
End With

but this dosnt work
 
Try this code

toGrid.DataSource = dset.Tables("Mittel")
Dim TableStyle As New DataGridTableStyle
TableStyle.MappingName = "Mittel"
Dim DictionrGridColumns As New DataGridTextBoxColumn
With DictionrGridColumns
..MappingName = "name"
..HeaderText = "Name"
..Width = 40
End With
' Define Dictionary Grid Columns Styles
toGrid.TableStyles.Clear()
toGrid.TableStyles.Add(TableStyle)
End With

Make sure your mapping names are correct.

Hope this helps,
Cheers,
Arun.
www.innasite.com
 
Back
Top