D
DraguVaso
Hi,
I need a function that gives me the number of Columns shown in a DataGrid.
So I don't need to know the number of columns shown in tha DataSource,
because this number can be completely something else than the number of
columns defined in the currently active TableStyle!
I currently use DataGrid.TableStyles(0).GridColumnStyles.Count, but i know
this won't work when using more than one TableStyle, or having a TableStyle
with another mappingname...
Has anybody any idea?
Maybe a combination of these 2 functions that search first which type of
DataSource I have, if it has a table, and if there is a TableStyle with that
name etc? But it doesn't seem really logical to me, and I really wonder if
there isn't any method that gets it directly from the DataGrid?
Thanks a lot in advance,
Pieter
private void PrintCurrentListName(DataGrid myDataGrid){
CurrencyManager myCM = (CurrencyManager)
BindingContext[myDataGrid.DataSource, myDataGrid.DataMember];
IList myList = myCM.List;
ITypedList thisList = (ITypedList) myList;
Console.WriteLine(thisList.GetListName(null));
}
Private Function GetColumnCount() As Integer
Dim intCount As Integer
If TypeOf Me.DataSource Is DataTable Then
intCount = DirectCast(Me.DataSource, DataTable).Columns.Count
ElseIf TypeOf Me.DataSource Is DataView Then
intCount = DirectCast(Me.DataSource,
DataView).Table.Columns.Count
ElseIf TypeOf Me.DataSource Is ArrayList Then
intCount = DirectCast(Me.DataSource, ArrayList).Count '????
ElseIf TypeOf Me.DataSource Is Collection Then
intCount = DirectCast(Me.DataSource, Collection).Count '????
ElseIf TypeOf Me.DataSource Is DataSet Then
intCount = DirectCast(Me.DataSource,
DataSet).Tables(0).Columns.Count
Else
intCount = 0
End If
Return intCount
End Function
I need a function that gives me the number of Columns shown in a DataGrid.
So I don't need to know the number of columns shown in tha DataSource,
because this number can be completely something else than the number of
columns defined in the currently active TableStyle!
I currently use DataGrid.TableStyles(0).GridColumnStyles.Count, but i know
this won't work when using more than one TableStyle, or having a TableStyle
with another mappingname...
Has anybody any idea?
Maybe a combination of these 2 functions that search first which type of
DataSource I have, if it has a table, and if there is a TableStyle with that
name etc? But it doesn't seem really logical to me, and I really wonder if
there isn't any method that gets it directly from the DataGrid?
Thanks a lot in advance,
Pieter
private void PrintCurrentListName(DataGrid myDataGrid){
CurrencyManager myCM = (CurrencyManager)
BindingContext[myDataGrid.DataSource, myDataGrid.DataMember];
IList myList = myCM.List;
ITypedList thisList = (ITypedList) myList;
Console.WriteLine(thisList.GetListName(null));
}
Private Function GetColumnCount() As Integer
Dim intCount As Integer
If TypeOf Me.DataSource Is DataTable Then
intCount = DirectCast(Me.DataSource, DataTable).Columns.Count
ElseIf TypeOf Me.DataSource Is DataView Then
intCount = DirectCast(Me.DataSource,
DataView).Table.Columns.Count
ElseIf TypeOf Me.DataSource Is ArrayList Then
intCount = DirectCast(Me.DataSource, ArrayList).Count '????
ElseIf TypeOf Me.DataSource Is Collection Then
intCount = DirectCast(Me.DataSource, Collection).Count '????
ElseIf TypeOf Me.DataSource Is DataSet Then
intCount = DirectCast(Me.DataSource,
DataSet).Tables(0).Columns.Count
Else
intCount = 0
End If
Return intCount
End Function