|
-
Dec 21st, 2006, 10:24 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] [2005] Declaring properties on custom control
I am creating a custom control with a gridview on it along with a databindingsource and a databindingnavigator. I have created a custom property datasource, but am stuck on how to add the "new" feature to it so that it can find/create a datasource......
This is what I have so far.
VB Code:
<Category("Data"), _
Description("Indicates the Source of the Control"), _
RefreshProperties(RefreshProperties.Repaint), AttributeProvider(GetType(IListSource))> _
Public Property DataSource() As Object
Get
Return (Me.dgvEditSearchPanel.DataSource)
End Get
Set(ByVal value As Object)
Me.dgvEditSearchPanel.DataSource = value
End Set
End Property
<Category("Data"), _
Description("Indicates a sub-list of the data source to show in the control.")> _
Public Property Datamember() As String
Get
Return Me.dgvEditSearchPanel.DataMember
End Get
Set(ByVal value As String)
Me.dgvEditSearchPanel.DataMember = value
End Set
End Property
Thank you!
D
Last edited by dminder; Dec 21st, 2006 at 04:40 PM.
-
Dec 21st, 2006, 05:39 PM
#2
Re: [2005] Declaring properties on custom control
I suggest that you get yourself .NET Reflector so that you can look inside the Framework, and other, assemblies. It's useful for all sorts of things, including seeing what attributes are applied to various members. The DataGridView.DataSource property is decorated with the AttributeProvider attribute like so:
AttributeProvider(GetType(IListSource))
I would guess that that is what controls the behaviour that allows you to pick a data source in the designer. The DataMember property is decorated with the Editor attribute like so:
Editor("System.Windows.Forms.Design.DataMemberListEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", GetType(UITypeEditor))
-
Dec 22nd, 2006, 09:19 AM
#3
Thread Starter
Fanatic Member
Re: [2005] Declaring properties on custom control
I downloaded that resource, although I am finding that it is a bit confusing to work with. Thank you for that addition to Datamember that gives me the same type list that datasource has to work with. Also, I have included AttributeProvider in the DataSource declaration. I have not found anything more yet so if you or anybody else has some additional insight it is greatly appreciated.
Oh and Happy Holidays to all of you (who celebrate it anyways)!!
D
-
Dec 22nd, 2006, 12:03 PM
#4
Thread Starter
Fanatic Member
Re: [2005] Declaring properties on custom control
After alot more digging i found the answer. It is in a somewhat related article found here:
http://msdn.microsoft.com/library/de...et02252003.asp
the code i needed is this:
VB Code:
TypeConverter("System.Windows.Forms.Design.DataSourceConverter, System.Design")
For anybody who wants to create a databound control, I think this article rocks. Good luck and marking this thread resolved......
-
Dec 22nd, 2006, 08:31 PM
#5
Re: [RESOLVED] [2005] Declaring properties on custom control
Nice link. I've bookmarked that myself.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|