473,320 Members | 1,920 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.

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 6993
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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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...
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...

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.