PC Review


Reply
Thread Tools Rate Thread

Databound User Control with two ListBoxes

 
 
Evan M.
Guest
Posts: n/a
 
      12th Nov 2008
Hello

I'm trying to create a user control for myself that has two ListBoxes
in it. The two ListBoxes will be databound to BindingSources on the
parent form. I've got the DataSource properties exposed, and added
designer support in VS2005 using the [AttributeProvider (typeof
(IListSource))] tag, but how do I expose the DisplayMember &
ValueMember properties in a similar manner, so that I can select them
from a drop down list, rather than having to type the names into the
properties window myself?

My current code (not including the *.designer.cs code):

public MyNamespace {
public partial class MyUserControl {

[AttributeProvider (typeof(IListSource))]
public object ListBox1DataSource {
get { return this.listbox1.DataSource; }
set { this.listbox1.DataSource = value; }
}

[AttributeProvider (typeof(IListSource))]
public object ListBox2DataSource {
get { return this.listbox2.DataSource; }
set { this.listbox2.DataSource = value; }
}

public string ListBox1DisplayMember {
get { return this.listbox1.DisplayMember; }
set { this.listbox1.DisplayMember = value; }
}

public string ListBox1ValueMember {
get { return this.listbox1.ValueMember; }
set { this.listbox1.ValueMember = value; }
}

public string ListBox2DisplayMember {
get { return this.listbox2.DisplayMember; }
set { this.listbox2.DisplayMember = value; }
}

public string ListBox2ValueMember {
get { return this.listbox2.ValueMember; }
set { this.listbox2.ValueMember = value; }
}

}
}

Thanks,
Evan
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using values in non-databound listboxes Scott McNair Microsoft VB .NET 6 7th Feb 2008 05:53 AM
user control to custom databound control =?Utf-8?B?cm9kY2hhcg==?= Microsoft ASP .NET 2 4th Dec 2007 02:22 PM
Databound control does not appear upon entry Dave Microsoft ASP .NET 1 19th Jun 2007 04:35 PM
Can't access databound dropdownlist properties in user control =?Utf-8?B?QVNQIERldmVsb3Blcg==?= Microsoft ASP .NET 0 8th Nov 2005 12:07 AM
Databound control problem =?Utf-8?B?SXVsaWFuIElvbmVzY3U=?= Microsoft Dot NET Framework Forms 1 2nd Feb 2004 03:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:09 PM.