I've been searching and can't find anything on the subject. I'd like to make a control that has a DataSource, ValueMember & DisplayMember just like all the regular WindowsForms Controls. Is there a standard way of doing this Any links to anything would really be great. Seems like everything I find that might be useful is for ASP.NET Controls :(
<edit>
Also, I noticed if I declare a DataSource As Object Property, it's always disabled in the Property window. I'm guessing since it doesn't know what to do with an Object, so my guess is that you have to have a TypeConverter for that Property, but how would I get the drop down to show all bindable sources Any articles on this sort of thing
</edit>

Creating a Bindable Control
CreweAlex
bswaters
<TypeConverter("System.Windows.Forms.Design.DataSourceConverter, System.Design")>
into
<TypeConverter(System.Windows.Forms.Design.DataSourceConverter)>
and including a reference to System.Design (which should work and have the added advantage of being type-safe), gives the following compiler error:
'System.Windows.Forms.Design.DataSourceConverter' is inaccessible due to its protection level
So I guess the class does exist, but is probably internal or something. TypeConverter seems to have little trouble getting to the class definition by it's string name. The visibility level of this class also explains why it doesn't show up in the object browser or the help.
Wierd that the crew at Microsoft made the webform variant public and the winform one not...
Dados
Darshita
Dmorris
telugodu
WinFormsUser13232
is there ANY support for that or do i have to hardcode what interfaces should be allowed to be bound
i mean , you can bind an arraylist to a datagrid.
if i want to do the same in my control , do i have to specify that IList is a valid interface and then use reflection to get the propps on the items
//Roger
Christina LW
Make sure you pasted the code exactly the same.
If you can't get it working, post the code you're using and we'll see if we can reproduce the error, because it's working just fine here.
Victor Irzak
leabre
NiklasL
(so i a list of rows and each row has columns (which in the case of ilist content would be properties of the stored objects)
there is no built in way to do that , right
i will have to use reflection when i deal with objects in the ilist and read the fields of rows when reading from the datatable right
//Roger
trhodes
John Mac
I am using the 1.1 version of the framework, maybe Microsoft took it out and that's the problem Otherwise, I don't have a clue.
I you have any further suggestions, I would be very grateful.
Bas.
Stalkers
Public Class MyControl
Inherits Control
Private m_DataSource As Object
Private m_DataMember As String
Private m_ValueMember As String
Private m_DisplayMember As String
<RefreshProperties(RefreshProperties.All), TypeConverter("System.Windows.Forms.Design.DataSourceConverter, System.Design")> _
Public Property DataSource() As Object
Get
Return m_DataSource
End Get
Set(ByVal Value As Object)
m_DataSource = Value
End Set
End Property
<Editor("System.Windows.Forms.Design.DataMemberListEditor, System.Design", "System.Drawing.Design.UITypeEditor, System.Drawing")> _
Public Property DataMember() As String
Get
Return m_DataMember
End Get
Set(ByVal Value As String)
m_DataMember = Value
End Set
End Property
<Editor("System.Windows.Forms.Design.DataMemberFieldEditor, System.Design", "System.Drawing.Design.UITypeEditor, System.Drawing")> _
Public Property ValueMember() As String
Get
Return m_ValueMember
End Get
Set(ByVal Value As String)
m_ValueMember = Value
End Set
End Property
<Editor("System.Windows.Forms.Design.DataMemberFieldEditor, System.Design", "System.Drawing.Design.UITypeEditor, System.Drawing"), TypeConverter("System.Windows.Forms.Design.DataMemberFieldConverter")> _
Public Property DisplayMember() As String
Get
Return m_DisplayMember
End Get
Set(ByVal Value As String)
m_DisplayMember= Value
End Set
End Property
End Class