|
Hi all!
I'm populating a DataGridView with generic lists of my interfaces and I got this issue:
I have two interfaces and to concrete implementations of them:
Public Interface IMyBaseClass
Property Name() As String
End Interface
Public MustInherit Class MyBaseClass
Implements IMyBaseClass
Private _name As String
Public Property Name() As String Implements IMyBaseClass.Name
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
End Class
Public Interface IMyConcreteClass
Inherits IMyBaseClass
Property Description() As String
End Interface
Public Class MyConcreteClass
Inherits MyBaseClass
Implements IMyConcreteClass
Private _description As String
Public Property Description() As String Implements IMyConcreteClass.Description
Get
Return _description
End Get
Set(ByVal value As String)
_description = value
End Set
End Property
End Class
If I bind my grid with a generic list of IMyConcreteClass, the grid just loads the concrete interface propertys (Description) but doesn't loads the base interface propertys (Name).
Here is an example of what i'm doing:
Public Sub LoadTheGride()
'load some data ont mylist
Dim classOne As New MyConcreteClass
Dim classTwo As New MyConcreteClass
classOne.Name = "class one"
classOne.Description = "the class one"
classTwo.Name = "class two"
classTwo.Description = "the class two"
Dim myList As List(Of IMyConcreteClass) = New List(Of IMyConcreteClass)
myList.Add(classOne)
myList.Add(classTwo)
'add respective columns
Dim someGrid As New DataGridView 'actually the grid is in my form but this is just an example
Dim column1 As New DataGridViewTextBoxColumn()
Dim column2 As New DataGridViewTextBoxColumn()
column1.DataPropertyName = "Name"
column1.Name = "The name"
column2.DataPropertyName = "Description"
column2.Name = "The description"
someGrid.Columns.Add(column1)
someGrid.Columns.Add(column2)
'bind
Dim bs As New BindingSource()
someGrid.AutoGenerateColumns = False
someGrid.DataSource = bs
bs.DataSource = myList
End Sub
At the end i just got this on the screen:
http://img140.imageshack.us/img140/6060/clipboard01au4.png (screencap)
Some one knows what I'm doing wrong?
modified on Thursday, November 20, 2008 8:30 PM
|
|
|
|
|
Tried to look at the screen cap, but the link didn't work for me.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
fixed :P
http://img140.imageshack.us/img140/6060/clipboard01au4.png
|
|
|
|
|
Not sure what exactly is going on. What appears to be happening is when adding the desc and name to the mylist, the intelli-sense correctly picks up the properties.
When putting a breakpoint on the last line (binding the bs.dataSource = mylist) and viewing the mylist items, the name property is nested. Guessing that databinding isn't picking up the nested property under AppName_Interfaces.MyConcreteClass
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|