Re: Filling a Listbox on a User Control



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
.



Relevant Pages

  • Re: Cant select Item in a list box
    ... So each Button simply controls if the corresponding ListBox ... >>> control in regards to the settings saved in the table. ... I have a user control which consists of three buttons, ... >>> Private Sub IntitializeCtls() ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Cant select Item in a list box
    ... item in lsitbox, label displays"Filtered", User selects all..Label Display ... I have a user control which consists of three buttons, ... listbox is made visible. ... Private Sub IntitializeCtls() ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Cant select Item in a list box
    ... So each Button simply controls if the corresponding ListBox is ... > control in regards to the settings saved in the table. ... I have a user control which consists of three buttons, ... > Private Sub IntitializeCtls() ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Advice on coding my classes
    ... I have a user control which consists of three buttons, ... for listbox which inherits listbox. ... Private Sub IntitializeCtls() ... Private Sub Button_click(ByVal sender As System.Object, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: need help: list box showing item selected when none are
    ... contorls inside the user control available to me.... ... > you did mean the listbox in the usercontrol. ... > You have bound that listbox in the usercontrol to that dataclass USState ...
    (microsoft.public.dotnet.languages.vb)