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

ComboBox Question

I provide a bunch of items at form load for the combo box.

What I want to do is if the user chooses to enter a value not in the item
list I want to be able to grab that and assign it to a string variable.

is this possible?

Nov 20 '05 #1
8 7007
Hello,

"scorpion53061" <sc************@yahoo.com> schrieb:
I provide a bunch of items at form load for the combo box.

What I want to do is if the user chooses to enter a value not
in the item list I want to be able to grab that and assign it
to a string variable.


You can use the combobox's 'FindString' and 'FindStringExact' methods to
check if a string is contained in the item list.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #2
drnew.Item("TYPE") = ComboBox1.Text.ToString

This doesnt add what the user put in the combo box.

What do you think would?

"Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> wrote in message
news:O7**************@TK2MSFTNGP10.phx.gbl...
Hello,

"scorpion53061" <sc************@yahoo.com> schrieb:
I provide a bunch of items at form load for the combo box.

What I want to do is if the user chooses to enter a value not
in the item list I want to be able to grab that and assign it
to a string variable.


You can use the combobox's 'FindString' and 'FindStringExact' methods to
check if a string is contained in the item list.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet

Nov 20 '05 #3
Cor
Scorpion
I should try to put it in a messagebox first to test it
For me it works
drnew.Item("TYPE") = ComboBox1.Text.ToString

messagebox.show(combobox1.text.toString)

I hope this helps you a little bit.
Cor
Nov 20 '05 #4
Hello,

"scorpion53061" <sc************@yahoo.com> schrieb:
drnew.Item("TYPE") = ComboBox1.Text.ToString
You don't need to call 'ToString' here, 'Text' will return a string.
This doesnt add what the user put in the combo box.


What is 'drnew'? Are you working with a databound combobox?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #5
Nak
> drnew.Item("TYPE") = ComboBox1.Text.ToString

This doesnt add what the user put in the combo box.


Are you wanting to add to the same combo box that the user has selected
from? To add items to a combo box you need to use the add method of the
items collection...

combobox1.Items.Add("my string")

But when do you want to add to the combo box? After the user has finished
typing? Remember there is no way to know if the user has *finished* typing
as such unless you actually use a timer, which is a bit of a fudge. Maybe
check for the enter key being pressed in the keydown event?

Private Sub ComboBox1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles ComboBox1.KeyDown
If (e.KeyCode = Keys.Enter) Then
If (ComboBox1.FindStringExact(ComboBox1.Text) = -1) Then
Call ComboBox1.Items.Add(ComboBox1.Text)
End If
End If
End Sub

But then again I might have the wrong idea about what you want?

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #6
Hi Herfried,

drnew = drNew = datarowNew ;-)

Regards,
Fergus
Nov 20 '05 #7
Correct herfried......
I am trying to add the combobox control's text as a entry in a dataset even
if the user had changed it.

"Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> wrote in message
news:ep*************@tk2msftngp13.phx.gbl...
Hello,

"scorpion53061" <sc************@yahoo.com> schrieb:
drnew.Item("TYPE") = ComboBox1.Text.ToString


You don't need to call 'ToString' here, 'Text' will return a string.
This doesnt add what the user put in the combo box.


What is 'drnew'? Are you working with a databound combobox?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet

Nov 20 '05 #8
Hello,

"Fergus Cooney" <fi******@tesco.net> schrieb:
drnew = drNew = datarowNew ;-)


That's what I thought, but I was not sure.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #9

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

Similar topics

10
by: Mr. B | last post by:
I've been seeking the solution to this. But can't figure it out (sounds simple enough). When you Populat a ComboBox, you can select the initial displayed items on startup simply by setting the...
6
by: Georges Heinesch | last post by:
An easy ComboBox question. ;) I would like to create a ComboBox, which permits to cycle through 3 subforms. These 3 subforms are entered in the ComboBox as Value List. The subforms should only...
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...
4
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
4
by: Beeeeeeeeeeeeves | last post by:
I have an ownerdrawn combo box which I am drawing with an image and some text, this is all working beautifully apart from the difference in the Brush I have to draw the background and the text with...
0
by: Hiroyuki Tanaka | last post by:
Hi All, I am trying to develop an application for a touch screen using buttons for the numeric pad with Completion ComboBoxes. At the moment I am having a problem sending the button presses to...
2
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know...
6
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...
6
by: Hal Heinrich | last post by:
How do I implement the value equivalent of the ComboBox.FindStringExact method? I.e. How do I set the ComboBox.SelectedIndex so that the ComboBox.SelectedValue object matches one that I specify....
4
by: JJGarcia | last post by:
Hi Everyone, I'll try to explain the process I'm following, I'm new to this so I'm triying the easy way first, probably the lasyest too! I created a new Project, drag in to it a SQLConnection,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
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...

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.