473,569 Members | 2,844 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Combobox Additions at Run-Time

I have Visual Studio .NET with all of the components installed onto it. I
want to add items to a combo box at run-time through numerous subroutines. I
previously did it with the combo boxes AddItem method, but in .NET's version
it gives me an error, because the method no longer exists. I know I can use
the Items property, but that is Read-Only at run-time.

I previously used Microsoft Visual Basic 6 (not a Visual Studio component)
and it worked fine before, but now the AddItem and RemoveItem methods are
gone.
Nov 21 '05 #1
5 3072

Jan. 13, 2005

No, you can't add items to the collection by using:

dim coll as objectcollectio n
coll = combobox1.items
coll.add("...")

You can add items at runtime though with:

combobox1.Items .Add("MyItem")

I hope this answers your question and I hope you have a great day!
Joseph MCAD

"Chaos2651" wrote:
I have Visual Studio .NET with all of the components installed onto it. I
want to add items to a combo box at run-time through numerous subroutines. I
previously did it with the combo boxes AddItem method, but in .NET's version
it gives me an error, because the method no longer exists. I know I can use
the Items property, but that is Read-Only at run-time.

I previously used Microsoft Visual Basic 6 (not a Visual Studio component)
and it worked fine before, but now the AddItem and RemoveItem methods are
gone.

Nov 21 '05 #2
"Chaos2651" <Ch*******@disc ussions.microso ft.com> schrieb:
I have Visual Studio .NET with all of the components installed onto it. I
want to add items to a combo box at run-time through numerous subroutines.
I
previously did it with the combo boxes AddItem method, but in .NET's
version
it gives me an error, because the method no longer exists. I know I can
use
the Items property, but that is Read-Only at run-time.


\\\
Me.ListBox1.Ite ms.Add("Hello World")
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #3
Why do you think this will not work? You are just making a reference to the
collection and then adding items to that collection. It will work.

Dim ComboBox1 As New ComboBox
Dim coll As ComboBox.Object Collection
coll = ComboBox1.Items
coll.add("...")
MessageBox.Show (ComboBox1.Item s.Count)

Chris
"Joseph MCAD" <Jo********@dis cussions.micros oft.com> wrote in message
news:E9******** *************** ***********@mic rosoft.com...

Jan. 13, 2005

No, you can't add items to the collection by using:

dim coll as objectcollectio n
coll = combobox1.items
coll.add("...")

You can add items at runtime though with:

combobox1.Items .Add("MyItem")

I hope this answers your question and I hope you have a great day!
Joseph MCAD

"Chaos2651" wrote:
I have Visual Studio .NET with all of the components installed onto it. I
want to add items to a combo box at run-time through numerous
subroutines. I
previously did it with the combo boxes AddItem method, but in .NET's
version
it gives me an error, because the method no longer exists. I know I can
use
the Items property, but that is Read-Only at run-time.

I previously used Microsoft Visual Basic 6 (not a Visual Studio
component)
and it worked fine before, but now the AddItem and RemoveItem methods are
gone.

Nov 21 '05 #4
Thank you for a quick and speedy reply! I didn't know that the Items property
had subroutines. I'm more of a C++ guy rather than VB.

Thanks!

"Joseph MCAD" wrote:

Jan. 13, 2005

No, you can't add items to the collection by using:

dim coll as objectcollectio n
coll = combobox1.items
coll.add("...")

You can add items at runtime though with:

combobox1.Items .Add("MyItem")

I hope this answers your question and I hope you have a great day!
Joseph MCAD

"Chaos2651" wrote:
I have Visual Studio .NET with all of the components installed onto it. I
want to add items to a combo box at run-time through numerous subroutines. I
previously did it with the combo boxes AddItem method, but in .NET's version
it gives me an error, because the method no longer exists. I know I can use
the Items property, but that is Read-Only at run-time.

I previously used Microsoft Visual Basic 6 (not a Visual Studio component)
and it worked fine before, but now the AddItem and RemoveItem methods are
gone.

Nov 21 '05 #5

Jan. 13, 2005

Your welcome! And the reason that your code won't work Chris, is
because the collection returned by ComboBox1.Items is readonly.

Dim ComboBox1 As New ComboBox
Dim coll As ComboBox.Object Collection
coll = ComboBox1.Items 'This returns a readonly collection and cannot be
added to
coll.add("...")
MessageBox.Show (ComboBox1.Item s.Count)

You must add to the collection through the combobox instead. Have a
great day!
Joseph MCAD
"Chaos2651" wrote:
Thank you for a quick and speedy reply! I didn't know that the Items property
had subroutines. I'm more of a C++ guy rather than VB.

Thanks!

"Joseph MCAD" wrote:

Jan. 13, 2005

No, you can't add items to the collection by using:

dim coll as objectcollectio n
coll = combobox1.items
coll.add("...")

You can add items at runtime though with:

combobox1.Items .Add("MyItem")

I hope this answers your question and I hope you have a great day!
Joseph MCAD

"Chaos2651" wrote:
I have Visual Studio .NET with all of the components installed onto it. I
want to add items to a combo box at run-time through numerous subroutines. I
previously did it with the combo boxes AddItem method, but in .NET's version
it gives me an error, because the method no longer exists. I know I can use
the Items property, but that is Read-Only at run-time.

I previously used Microsoft Visual Basic 6 (not a Visual Studio component)
and it worked fine before, but now the AddItem and RemoveItem methods are
gone.

Nov 21 '05 #6

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

Similar topics

1
4771
by: Oren Kaplan | last post by:
Hello, I posted a msg on the Access-related groups in hope someone there could help me but since almost two days have past and I didnt get a response (Im a bit hard pressed with the problem) I thought I might try some of you guys since you also deal with the Visual part of visual basic and since vba shouldn`t be all that different from vb.......
3
7478
by: Wayne Wengert | last post by:
I am trying to populate a combobox with a lisy of items. I want the 1st item to be "Make a Selection" and the following items will be names from a table in my DB (See code below). When I run the project, the combox box initially displays an empty selection. When I click on the drop down arrow I see the "Make a Selection" followed by the...
1
1164
by: Tonya | last post by:
Hi, I want to write code that will fill my combobox ONLY IF it is currently empty. i need this code to run for the combobox1.selectedindexchanged event. i wanted to know how i can code this. I have tried the following if combobox1.items.count = 0 then 'run the code to add items to the combobox1
5
3055
by: Steve | last post by:
I have an unbound combobox in the form header of a continuous form. The selection in the combobox sets the where clause in a querydef which determines QryPFrmInventoryManagement. The following code is in the afterupdate event of the combobox: Me.RecordSource = "QryPFrmInventoryManagement" Me!ItemCount = Me.RecordsetClone.RecordCount & "...
1
2315
by: jdk | last post by:
I have a main form where a students name is selected. After selected the name- the subform populates all criteria related to the students program. I have 2 combo boxes in the subform that determine the data in the third combobox. The problem is that if I run the subform by itself, the combobox shows the exact data that I want. However when...
6
3174
by: Cro | last post by:
Dear Access Developers, The 'Allow Additions' property of my form is causing unexpected results. I am developing a form that has its 'Default View' property set to 'Continuous Forms' and am displaying records that match an SQL statement entered in the 'Record Source' property of the form. The form behaves correctly and displays the...
1
3361
by: polocar | last post by:
Ciao a tutti, leggendo qua e là per il forum ho scoperto che non sono l'unico ad avere questo problema. Se si inserisce un controllo ComboBox in un form di C#, non è possibile impostare la sua altezza ad un valore diverso da 21. Forse, cambiando la dimensione del font, si potrebbe riuscire a cambiare anche l'impostazione dell'altezza... (MS...
0
2000
by: Frnak McKenney | last post by:
Can I use a bound ComboBox for both browsing and editing? I'm working on a small, standalone database application using Visual C#.NET 2003 and an Access data file. In order to keep the number of different screens down to a minimum, I'm trying to use the same Windows Forms for both browsing and for updating. This works fine for TextBoxes,...
2
1324
by: graywolf | last post by:
Hi there, I have just started using Access 2003 in the last couple of months and have a couple of problems i would like some help with please for a project i am working on. PROBLEM 1. I have a ComboBox (cboSelect) on my form (frmSelectCompany). I am populating this combobox with data from my OrderTable. The problem is if a company has...
1
4222
by: Andrus | last post by:
I need to enter null value from combobox to business object property. My combobox datasource does not contain ValueMember with null value. So I tried to create combobox which stores null to bound object when text is deleted. However bound object contains old value in this case. To reproduce: 1. Run code
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7668
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
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...
1
5509
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...
0
5218
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...
0
3653
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...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.