Re: Filling a Listbox on a User Control
- From: "Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx>
- Date: Wed, 13 Jun 2007 13:39:42 -0700
On Wed, 13 Jun 2007 13:25:54 -0700, <markr1000@xxxxxxxxxxxxx> wrote:
[...]
I have a Listbox on a User Control because I want to control the
visibility and/or presence of the Listbox and associated label, and I
want to encapsulate some of associated code.
I want to be able to pass the collection of strings that will fill the
Listbox to the User Control and have it pass on the collection to the
Listbox, preferably through Listbox.Items.AddRange.
Well, the basic idea would be to retrieve the ListBox somehow and operate on it directly from within code in your UserControl.
How you want to encapsulate that is up to you, and depends on who you want to have direct access to the ListBox. But the ListBox itself is still there an accessible by the usual means. You can reference it by name, or you can enumerate the members of the UserControl's Controls collection, looking for the ListBox (either by the Name property or by looking for something that is a ListBox, for example).
What you want to do is not hard, and perhaps the simplicity of doing so is why you are unable to find any examples. Perhaps you can be more specific about what exactly you're having trouble with.
Pete
.
- Follow-Ups:
- Re: Filling a Listbox on a User Control
- From: markr1000
- Re: Filling a Listbox on a User Control
- References:
- Filling a Listbox on a User Control
- From: markr1000
- Filling a Listbox on a User Control
- Prev by Date: Re: Need help with Vector parameter when invoking C dll from C#
- Next by Date: EventLogPermission, EventLog and no user logged.
- Previous by thread: Filling a Listbox on a User Control
- Next by thread: Re: Filling a Listbox on a User Control
- Index(es):
Relevant Pages
|