I am using ArrayDataView from the following link, my question is how do I
apply column styles to this DataGrid that uses ArrayDataView instead of
DataSet
http://www.codeproject.com/cs/databa...dArrayGrid.asp
I have tried the following code, but it has no effect
Private Sub CreateColumnStyles(ByVal grd As DataGrid)
Dim tableStyle As New DataGridTableStyle
Dim tableGrid As ArrayDataView = Nothing
Try
tableGrid = CType(grd.DataSource, ArrayDataView)
'
' Clear any existing table styles.
'
grd.TableStyles.Clear()
'
' Use mapping name that is defined in the data source.
'
tableStyle.MappingName = ""
'
' Now create the column styles within the table style.
'
Dim columnStyle As DataGridTextBoxColumn
Dim currCol As Integer
Dim colNames As String() = tableGrid.ColumnNames()
For currCol = 0 To tableGrid.Data.GetUpperBound(0) - 1
columnStyle = New DataGridTexBoxColumn
With columnStyle
.HeaderText = colNames(currCol)
.MappingName = colNames(currCol)
.NullText = ""
End With
'
' Add the new column style to the table style.
'
tableStyle.AlternatingBackColor =
System.Drawing.Color.Lavender
tableStyle.GridColumnStyles.Add(columnStyle)
Next currCol
'
' Add the new table style to the data grid.
'
grd.TableStyles.Add(tableStyle)
Catch e As Exception
MessageBox.Show(e.Message)
End Try
End Sub
I have implemented the ITypeList in the ArrayDataView , but what do I return
forom
PropertyDescriptorCollection and GetListName
#region ITypedList Members
public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[]
listAccessors)
{
// TODO: Add ArrayDataView.GetItemProperties implementation
return null;
}
public string GetListName(PropertyDescriptor[] listAccessors)
{
// TODO: Add ArrayDataView.GetListName implementation
return null;
}
#endregion
Thank You
Peter