|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
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 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 Show quoteHide quote > 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 > Reidar,
Why not simple? str = cboName.text (your code is more listbox style with a combobox is the selectedtext in the textbox) Cor Show quoteHide quote "reidarT" <rei***@eivon.no> schreef in bericht news:ew%23a2w7mGHA.3588@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 > I found the answer myself. Just use me.cboName.Text
reidarT Show quoteHide quote "reidarT" <rei***@eivon.no> skrev i melding news:ew%23a2w7mGHA.3588@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 > Sorry,
I had not seen your reply before sending my message Cor Show quoteHide quote "reidarT" <rei***@eivon.no> schreef in bericht news:O6jWR%237mGHA.4960@TK2MSFTNGP04.phx.gbl... >I found the answer myself. Just use me.cboName.Text > reidarT > "reidarT" <rei***@eivon.no> skrev i melding > news:ew%23a2w7mGHA.3588@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 >> > >
ActiveX.exe and RaiseEvent
need help with a string manipulation. Late Binding Return Value Weirdness MDI Form loading Hindi numbers in Graphics class OpenFileDialog Handle Leak read textbox into array - vb2005 DataGridView Question - VB.NET 2005 determine which radiobutton in a groupbox is checked? Browsing Records |
|||||||||||||||||||||||