Re: UserControl Static ComboBox



Mark,

Create a string array with your 40 entries and store that where all 40
comboboxes can access it.

Then, set the DataSource property on each combobox to that array.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"Mark Jerde" <MarkJerde@xxxxxxxxxxxxxxxx> wrote in message
news:%230tg1MrkFHA.1996@xxxxxxxxxxxxxxxxxxxxxxx
> I'm not finding help in Google. VS .NET 2003.
>
> I have a user control with a ComboBox. At runtime the ComboBox gets
> loaded with a long list of strings. Since I have up to 40 controls on a
> form I'm trying to figure out a way for all 40 combobox controls to share
> the same list of items.
>
> The ComboBox.Items property is read only so setting all 40 to the same
> ObjectCollection won't work.
>
> On a whim I made the combobox static in the UC:
> private static System.Windows.Forms.ComboBox cboFields;
>
> This "works" from a data standpoint, as Items.innerlist is the same (and
> correct) in all 40 UCs after initializing the first one. But it doesn't
> work from the UI standpoint. The ComboBox control doesn't like being
> shared across multiple UCs.
>
> Suggestions? Or is there no alternative to haviing the same Items in all
> 40 instances?
>
> Thanks.
>
> -- Mark
>
>


.



Relevant Pages

  • Re: Means of Editing/Adding/Deleting VB6 ComboBox Selection Items
    ... address record is a single string like:1 first st, dallass, tx ... dallas, texas" and tried to replace texas with tx. ... > combobox controls on several of the data entry forms. ...
    (microsoft.public.vb.controls)
  • Means of Editing/Adding/Deleting VB6 ComboBox Selection Items
    ... combobox controls on several of the data entry forms. ... drop-down box and it's spelled incorrectly as "Dallass". ...
    (microsoft.public.vb.controls)
  • Re: UserControl Static ComboBox
    ... > Create a string array with your 40 entries and store that where all 40 ... set the DataSource property on each combobox to that array. ... >> form I'm trying to figure out a way for all 40 combobox controls to share ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Accessing Properties within a Panel
    ... The label controls are sequentially named Channel0 through Channel7, ... and the combobox controls are sequentially named Ch0 through Ch7, ... Apply button's click event to process the selections. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Populating a Combo Box with instances of a class - problem
    ... ComboBox does not know what to do with it except for calling its ToString ... DataSource property. ... > if you just added a bunch of strings to a combo box, ... > the combo box to display multiple entries, ...
    (microsoft.public.dotnet.framework.windowsforms)

Loading