473,320 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

No dups in a ComboBox?

I've been checking the doc for the combobox to see it there is some way I
can set it up to be sorted (I found that) and to have no duplicate entries.

I don't see any way to avoid dups unless Sorted implies that.

Is there a simple way to avoid dups or should I program to accomplish that?
Thanks
Nov 21 '05 #1
2 1415
On Mon, 9 Aug 2004 20:33:31 -0400, Just Me wrote:
I've been checking the doc for the combobox to see it there is some way I
can set it up to be sorted (I found that) and to have no duplicate entries.

I don't see any way to avoid dups unless Sorted implies that.

Is there a simple way to avoid dups or should I program to accomplish that?
Thanks


You can use the contains method to discover if an object already exists
before you add it...

If Not myCombo.Items.Contains(theValue) Then
myCombo.Items.Add (theValue)
End If

You can also use the FindString and FindStringExact methods to see if
certain text is contained...

If myCombo.FindStringExact("Dog") = -1 Then
myCombo.Items.Add ("Dog")
End If

HTH
--
Tom Shelton [MVP]
Nov 21 '05 #2
Perfect

Thanks

"Tom Shelton" <to*@YOUKNOWTHEDRILLmtogden.com> wrote in message
news:3w*****************************@40tude.net...
On Mon, 9 Aug 2004 20:33:31 -0400, Just Me wrote:
I've been checking the doc for the combobox to see it there is some way I can set it up to be sorted (I found that) and to have no duplicate entries.
I don't see any way to avoid dups unless Sorted implies that.

Is there a simple way to avoid dups or should I program to accomplish that?

Thanks


You can use the contains method to discover if an object already exists
before you add it...

If Not myCombo.Items.Contains(theValue) Then
myCombo.Items.Add (theValue)
End If

You can also use the FindString and FindStringExact methods to see if
certain text is contained...

If myCombo.FindStringExact("Dog") = -1 Then
myCombo.Items.Add ("Dog")
End If

HTH
--
Tom Shelton [MVP]

Nov 21 '05 #3

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

Similar topics

13
by: Mr. B | last post by:
Here's the situation... You've a combobox with Items already added. Say they look like this (or even lines of text): 10-00-232 10-00-256 10-01-006 10-01-213 10-02-200
7
by: Nicolae Fieraru | last post by:
Hi All, I am trying to change the rowsource of a combobox when I click on it. I played with many events, associated with the form and the combobox, but still haven't figured out what is the way...
1
by: KEVIN97810 | last post by:
Hello to all, I read data from SQL and populate a table. Howerver, there are dups that I need to prevent into my table. The dups only are in these two fields. How do you prevent this in the...
8
by: Zlatko Matiæ | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
1
by: anonymous | last post by:
I've been trying to put a them, please help me out. Here's the major parts of my code: public Form1() { DataSet myDataSet = new DataSet("myDataSet"); DataTable testTable = new...
3
by: TT (Tom Tempelaere) | last post by:
Hay there, I'm writing my own DataGridComboBoxColumn because .NET 1.1 does not have one (I hope .NET 2.0 supplies one). I based it on this article:...
2
by: Don | last post by:
I've looked high and low for some code that will allow me to have a combobox with a flat borderstyle. I found a few examples, but nothing that was really usable for me. I had the following...
4
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box...
6
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.