473,804 Members | 3,228 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

UserControl Static ComboBox

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
ObjectCollectio n 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
Nov 17 '05 #1
2 2518
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]
- mv*@spam.guard. caspershouse.co m

"Mark Jerde" <Ma*******@news group.nospam> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
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
ObjectCollectio n 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

Nov 17 '05 #2
Nicholas -- Thanks, that works great.

-- Mark

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:em******** ******@tk2msftn gp13.phx.gbl...
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]
- mv*@spam.guard. caspershouse.co m

"Mark Jerde" <Ma*******@news group.nospam> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
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
ObjectCollectio n 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


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1463
by: codymanix | last post by:
My problem is: I have comboboxes which resides in a usercontrol. Always when the usercontrol changes its visible status (the dialog is shown or you switch to the tabpage where the usercontrol is), all text is selected in the textfield of the combobox. Is this a Bug? If yes, is there a workaround? -- cody
1
3700
by: bob scola | last post by:
I have a csharp, VS 2003 solution for a winform application The application uses an object called a "matter" and the class is defined in matter.cs. I can load matter objects into a combobox Matter matters= v.Matters; comboBox1.Items.AddRange(matters);
2
2099
by: John B | last post by:
Hello I want to create a set of controls that have some common methods and properties. I was thinking that I should subclass the UserControl class and add these common features there and then base all my custom controls on this new MyUserControl Class. Is this the way to go? The MyUserControl would not actually have any UI component and should be abstract I think. Does this mena that I should not create the control by just selecting...
13
5350
by: Michael Maes | last post by:
Hi, I have a UserControl containing some controls of which one is a ComboBox. All the InternalControls are Private and some are allowed to be accessed through Public Methods. One of the things I would like to do (of course) is set the DataBindings. Something clearly is wrong with the approach I use, because I can't set the Properties in the Designer, the DataSource-Property appears like 'ReadOnly', there is no "dropdown" with the list from...
8
4149
by: ChrisK | last post by:
Hi, I'm beginner with VB.net and i have a trouble... At work, they decided to program with tabcontrol...and i'mm in charge of this ! There is my problem. I've a form with one tabcontrol (TBC1 ). This TBC1 contents n TabPages ( TBP1,2,3,..,n) For each TBPn i 've got an specific usercontrol which have controls and code ( data access, ... ).
1
2156
by: Jochen Berger | last post by:
Moin! I've 'composed' a special UserControl I need for my current project. On this Control I put a ComboBox. The user is not allowed to access the ComboBox directly (to protect some properties), so I used Properties to enable the user to do some things in design mode. It all works fine except for the Items property: public ComboBox.ObjectCollection Items {
9
15366
by: davidr | last post by:
Hi, I've researched this a lot and have a well understanding but still can't get the darn textbox in the javascript. I have a textbox that is set to runat="server" and I have a client function for a comboBox when selectitemindexchanged happens it will trigger. I know it goes into that because I did a alert("test"). Now in there I want to take the item in the comboBox and put it in the textbox that is runat="server". I know I have...
5
19710
by: Blue | last post by:
We have a custom word processing type editor built with C# and .NET 2.0 and we need to support typing in languages other than English. I want to be able to use the Windows IME to enter in text similar to how it works in a text box. For example, if I put focus on a TextBox and then switch my language on the language bar to Japanese or Chinese, several buttons appear on the language bar including Input Mode, Input Style, Conversion Mode,...
4
2473
by: Martin | last post by:
Hi everyone ! For those who haven't read my previous post, I have a problem with a UserControl. When I try to display it on a form, controls seem to appear one after one. In the following example, it's less visible because controls don't execute any code... Is someone has an idea of how I could solve this problem and also improve the method ShowUserControl. I try to figure out I could flicker effect when I press the button twice quickly.
0
9708
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10589
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10340
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10085
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7625
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3828
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.