By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,572 Members | 1,516 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,572 IT Pros & Developers. It's quick & easy.

DataGrid Custom Styles

P: n/a
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

Mar 23 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Peter,

I think that you would ask that to Mihail.

The datagrid is not that control that is made to use with every collection
class. One of the advantages of the DataGridView should be that this has
more posibilities in this.

Cor

"Peter" <pc*****@nospam.nospam> schreef in bericht
news:ev**************@TK2MSFTNGP09.phx.gbl...
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

Mar 23 '06 #2

P: n/a
Hi Peter,

Thanks for your post!

We can return a meaningful string for GetListName() method. Regarding
GetItemProperties() method, it requires some extra work to be done. You can
get some information regarding implementing this interface from the
articles below:
http://noiseehc.freeweb.hu/IListSource.html
http://www.freeweb.hu/noiseehc/DS.cs
"Really complex databinding: ITypedList with weakly typed collections "
http://weblogs.asp.net/fbouma/articles/115837.aspx

You may give this a try. However, I agree with "Cor Ligthert [MVP]" that
because we are not the author of the article, you'd better contact the
article author for the help regarding his article.

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 23 '06 #3

P: n/a
Peter,

In addition to the other comments. To use a table style with a
datagrid bound to an arraylist use arraylist as the tablestyles mapping
name. For collection use collection as the mapping name. A blank mapping
name will never work. I would try ArrayDataView for the mapping name.

Ken
---------------
"Peter" <pc*****@nospam.nospam> wrote in message
news:ev**************@TK2MSFTNGP09.phx.gbl...
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

Mar 23 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.