Hello!
I use DataGrid which displays data in several columns. Number of columns
depends on user prefferences (I mean: this is still the same query filling
datatable but I use "DataTable.Columns(i).ColumnMapping =
MappingType.Hidden" to hide columns which should be hidden). So, the code I
use every time to fill DataTable and display data in DataGrid looks like:
Private Sub xxxxx(...)
Dim firstTime as Boolean = true
if not dataset.Tables("table") is nothing
firstTime = false
dataset.Tables("table").Clear()
End If
For i = 0 to dataset.Tables("table").Columns.Count - 1
dataset.Tables("table").Columns(i).ColumnMapping = iif (condition,
MappingType.Hidden, MappingType.Element)
Next
If firstTime
dataGrid.DataSource = dataset.Tables("table").DefaultView
End If
End Sub
It works fine only at first. It sets some of columns visible and hides
others. But already in the second invocation there's no effect. Columns
which were visible are still visible and hidden ones are hidden.
Why?
Thanks for any help
|