473,396 Members | 1,785 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,396 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 1593
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
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...
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
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...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.