Hello, I have followed microsoft's Walkthrough: Creating Your Own Collection Class to create my own Collection object. I created the following classes:
Receipt, ReceiptItemCollection, ReceiptItem.
1. I have bound a datagrid to my ReceiptItemCollection.
2. I am having trouble customizing the appearance of the datagrid. (using this example) (basically nothing happens..datagrid is automatically creating columns)
I am supposed to specify a MappingName for the DataGridTableStyle and DataGridtextBoxColumn objects. This mappingName property is of type String. So i can't tell it to use the first column in the collection or the second...i must have column names apparently.
how do i know that i have names to map to in my custom Collection
---- SOURCE -----
Public Class ReceiptItemCollection Inherits System.Collections.CollectionBase Public ReadOnly Property Item(ByVal intIndex As Integer) As ReceiptItem Public Sub Add(ByVal ri As ReceiptItem) Public Sub Remove(ByVal intIndex As Integer) End Class |
Public Class ReceiptItem Private decAmount As Decimal Private strDescription As String Public Sub New(ByVal decAmount As Decimal, ByVal strDescription As String) End Class |

Extending DataGrid
jfcma38
1. Use the new Whidbey BindingList<T> list. It has the functionality needed to be used in DataBinding. In your case, you would created a BindingList<ReceiptItem>.
2. See above.
3. If you want to display data you should set DataGrid.DataSource to the instance of BindingList<ReceiptItem>. Also, please look into using the new Whidbey DataGridView control : it has a lot more features than the old DataGrid control.
KeFei Wang
Thanks.
David Schulze
You will need to install Whidbey.
The generic BindingList<T> is defined in the System.ComponentModel namespace.
The new DataGridView controls is defined in System.Windows.Forms namespace.
Hope this helps.
Daniel.
This posting is provided "as-is".
rdrenker
I've done some research and am attempting to be more specific in this post.
Summary: I have created a custom collection class. I am trying to bind a datagrid with the data in the collection. My problem is that i don't have any table names or column names to map the datagrid to for custom binding.
1. Is my problem that i have not chosen the correct base class for the ReceiptItemCollection Class
2. Would choosing a different class give me the interface i need
3. Should i be setting the DataGrid.DataSource to be my ReceiptItemCollection
Thanks for any input.