J
Jim Wooley
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
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