473,387 Members | 1,504 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,387 software developers and data experts.

Automatically add item to combo box

daniel aristidou
491 256MB
From what i know, to do this you bind a combo to a datatable.
(so the data keeps even when the file is shut)
You then add code that tells the combo box to add a new row with the data typed into the combo box ie the text if the datatable does not allready contain the typed text.
Ps i use visual basic 2008 express version
What code would be used if it has been bound to a datacolumn called :
dataset1.datatable1.column1
assuming the combo box is called : combobox1
From what i tried i managed to get this :
Expand|Select|Wrap|Line Numbers
  1. Private Sub ComboBox1_LostFocus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.LostFocus
  2.         If Not DataTable1.Rows.Contains(ComboBox1.Text) Then
  3.             DataTable1.NewRow()
  4.  
  5.  
  6.             Exit Sub
  7.         End If
  8.         ComboBox1.Refresh()
  9.     End Sub
Thanks for any help
Oct 18 '07 #1
0 1098

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: mal | last post by:
Sorry for repost - system added to another subject for some reason Have tried numerous ideas from the group to solve this one. It is such a simple example that it should be straightforward ! I...
1
by: Dave | last post by:
I have a problem which I know there is an answer to but have so far been unsuccessful in finding it. It is quite simple in theory. I have created a form which uses a table for lookup values and...
3
by: Linda | last post by:
Greetings! In order to keep better track a form with several combo-boxes, I've subclassed the ones that need to change in response to events on other controls on the form. An example of a...
9
by: Kay | last post by:
Hi all, Could you tell me the best way to add a blank item(as first item) in a data binded combo box? Because I think I didn't do it right and it generate an error if the second item(after the...
5
by: CCLeasing | last post by:
Hello, I have searched google but can not find a straight forward answer to my problem. Hopefuly someone will be kind enough to offer their expertise. Please forgive if this seems a bit convoluted...
0
by: CCLeasing | last post by:
Hello, I have searched google but can not find a straight forward answer to my problem. Hopefuly someone will be kind enough to offer their expertise. Please forgive if this seems a bit convoluted...
4
by: Cralis | last post by:
I have a Combo box, populated from a List<Objects>. The Object has a .name, and .id property. The combo box has been populated with these using DisplayMember and ValueMember. When I load the...
6
by: Smokey Grindle | last post by:
Say I have a combo box with the following simple object Public class MyObject public ID as integer public Name as string public overrides sub ToString() as string return name end sub end...
7
by: Brad Pears | last post by:
I have something strange going on - pretty sure it used to work before - and now it does not... Why does the following code not clear a combo box? Me.cboLocation.Text = String.Empty OR ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.