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

Home Posts Topics Members FAQ

combobox.items question

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.selec tedindexchanged 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
.....
.....
end if

i already have code to fill the combobox from my database
(this works fine), i am just not sure on to find out if
the combobox is currently empty so i know whether to run
this code or not.

thx in advance

Jul 21 '05 #1
1 1163
Hi Tonya,
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.selec tedindexchanged 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
.....
.....
end if

i already have code to fill the combobox from my database
(this works fine), i am just not sure on to find out if
the combobox is currently empty so i know whether to run
this code or not.


Your code should work ... or did you have any problems with it?

Regards,

--
Frank Eller [.NET MVP]
www.frankeller.de
..NET Developers Group Munich- www.munichdot.net

Jul 21 '05 #2

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

Similar topics

4
1744
by: David Sworder | last post by:
Hi, I have a ComboBox that contains 1,400 sorted items . Here's the list: abba apple ... cabba caccaa capple
3
916
by: Nikolay Petrov | last post by:
I have a Combo box, binded to a dataset With cmbCompany .DataSource = dsSpecContact .DisplayMember = "Companies.CompanyName" .ValueMember = "Companies.CompanyID" End With What I want is to change the SelectedIndex of this Combo Box by using the ValueMember or DisplayMemver values. I mean the "Companies.CompanyID" or...
5
25832
by: James P. | last post by:
Hello, For my new Windows application, all I want is to create an initial form to demo to the user to show them how it looks like with some data on it. So I figure the fastest way is to create some comboBox-es to show some data on them manually entered in the code without connecting to the database yet. It should be simple but somehow I...
6
7796
by: Sakharam Phapale | last post by:
Hi All, How to fill one ComboBox from other ComboBox control? 1) Only setting the reference does the trick but doesn't show items in control. If you see in immediate window, it shows the item count correctly
5
3072
by: Chaos2651 | last post by:
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...
9
7307
by: Don | last post by:
Is there any way to detect when an item has been added to the Items collection of a combobox or listbox? I am inheriting a Combobox and want to validate items before they are added to the combobox, but I can't find anything that will let me do that. - Don
2
1609
by: murdock | last post by:
I am having an issue with graphical corruption upon re-selecting a combobox which upon 'selected index change' event should list file names in that folder in a separate combobox. Here is the code: private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { IniFile INI = new IniFile(@"c:\\data\TM.ini"); string MisFileDir =...
9
2448
by: Franky | last post by:
I have a usercontrol that inherits from ComboBox I'd like to add the feature that the user can delete any item Best would be that he could right click an element and a messagebox would ask if he wanted to delete that element I can't find an event that would enable me to do that. I could copy the items into a text box, let him edit it...
1
2131
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I want to create a customized ComboBox where the methods ComboBox.Items.Add and ComboBox.Items.Insert will behave thusly: -- If the item is not present, add it. -- If the item is present, set the selected index to the item (without adding a duplicate). I know the basics of inheriting from user controls, so if this was merely overriding a...
11
3296
Frinavale
by: Frinavale | last post by:
This question is going to sound a little crazy but.........How do you set the selected item in a ComboBox? I am populating a ComboBox with a bunch of instances of a custom private class: For Each s as Something In MyListOfSomethings MyComboBox.Items.Add(New XYZListItem(s.ID,s.description)) Next MyComboBox.ValueMember = "ID"...
0
7693
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...
0
7605
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...
0
7917
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. ...
0
6277
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5501
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
5217
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
3651
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
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2105
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

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.