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.

Getting the text from a bound combobox.

I want to get the text from a bound combobox in a variable
I try to use strVar = me.cboName.SelectedText.Tostring, but it doesn't work.

reidarT
Jun 29 '06 #1
4 1587
I found the answer myself. Just use me.cboName.Text
reidarT
"reidarT" <re****@eivon.no> skrev i melding
news:ew****************@TK2MSFTNGP04.phx.gbl...
I want to get the text from a bound combobox in a variable
I try to use strVar = me.cboName.SelectedText.Tostring, but it doesn't
work.

reidarT

Jun 29 '06 #2
The behavior for SelectedText will vary depending on how you are populating
the box. You say the method doesn't work. What is it returning?

Be aware that if no value is selected in the combo box, SelectedText (as
well as SelectedValue) will be Nothing. Calling .ToString on Nothing may
result in an exception. Also, If you set the ValueMember of the ComboBox,
you can check the SelectedValue with the same potential for null exception
handling. Additionally, if you are binding an object with a property of type
string to SelectedText or SelectedValue, make sure to check for Nothing before
doing any processing on the value.

Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx
I want to get the text from a bound combobox in a variable I try to
use strVar = me.cboName.SelectedText.Tostring, but it doesn't work.

reidarT

Jun 29 '06 #3
Reidar,

Why not simple?

str = cboName.text

(your code is more listbox style with a combobox is the selectedtext in the
textbox)

Cor

"reidarT" <re****@eivon.no> schreef in bericht
news:ew****************@TK2MSFTNGP04.phx.gbl...
I want to get the text from a bound combobox in a variable
I try to use strVar = me.cboName.SelectedText.Tostring, but it doesn't
work.

reidarT

Jun 30 '06 #4
Sorry,

I had not seen your reply before sending my message

Cor

"reidarT" <re****@eivon.no> schreef in bericht
news:O6****************@TK2MSFTNGP04.phx.gbl...
I found the answer myself. Just use me.cboName.Text
reidarT
"reidarT" <re****@eivon.no> skrev i melding
news:ew****************@TK2MSFTNGP04.phx.gbl...
I want to get the text from a bound combobox in a variable
I try to use strVar = me.cboName.SelectedText.Tostring, but it doesn't
work.

reidarT


Jun 30 '06 #5

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

Similar topics

13
by: MLH | last post by:
I have a form with two controls: !! - combo box !! - text box A button on the form tries to run this SQL when clicked... INSERT INTO BodyMsgsSent (ToWhom, BodyText) SELECT DISTINCTROW !! AS...
8
by: ShyGuy | last post by:
Is it possible to use code to enter some text into a combo box and then have the cursor placed at the end of the text for more imput?
2
by: Thelma Lubkin | last post by:
Arno R <arraNOcomSPAM@tiscali.nl> wrote: :> user types Mary Jane Jones :> database has MaryJane Jones : I finally understand why...
1
by: ASP Yaboh | last post by:
I have a WinForm ComboBox that is populated by binding to a dataset that contains a list of employees (two columns: 1. employee id, 2. employee name). The id is bound to the ValueMember, the name...
1
by: Richard Bond | last post by:
Hi, I have a combobox that is bound to a list of text and values in a dataset. It is in Dropdown mode - which enables the user to type in their own text if they so wish. when I process the form,...
4
by: Joe Schmoe | last post by:
All I want to to be able to take a two-column DataReader (One column with the Item ID number, the other with Item Description text) and load it into a Windows Forms ComboBox (Set to DropDownList...
10
by: lorirobn | last post by:
Hi, I have a form with several combo boxes, continuous form format, with record source a query off an Item Table. The fields are Category, Subcategory, and Color. I am displaying descriptions,...
7
by: PW | last post by:
Hi, I have a form with unbound fields on it. The user selects a record from a recordset and I populate the unbound fields. When I try to change the unbound quantity text box, Access 2003 tells...
5
by: njb35 | last post by:
Hi all I'm beginning my foray from VBA into VB 2005 Express, and enjoying some of the efficiencies it provides! I'm stuck with some dataset handling however that I _think_ can be automated but...
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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: 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.