.NETGURU
Problem getting value from combobox and late binding
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.windowsforms.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

moondaddy
using vb.net 1.1 I have a combobox which I'm trying to get the selected
item's value. the problem is that this class uses Option Explicit On and
Option Strict On so the following line gets a compile error:

m_GoToID = CType(cmbGoTo.SelectedItem.row(0), Int32)

with the blue squiggly under cmbGoTo.SelectedItem.row(0)

and the compile error is:

Option Strict On disallows late binding

I populated the combo by binding it to a dataset table.

Can anyone help on this?

Thanks

--
Click here to reveal e-mail address

Reply to this message...
 
    
moondaddy
I figured it out. Earlier I had tried this:

objB.myCombo = CType(myCombo.SelectedValue, Int32)

but got an error (I forget just what the error was), but I've figured out
how to make this line work. In order to use 'SelectedValue', I needed to
first define the value member. So when I load data into the combo, I call
this line:

Me.myCombo.ValueMember = "ID"

Where ID is the name if the ID column in the dataset.

Now it works and compiles too when using Option Strict On.

--
Click here to reveal e-mail address
"moondaddy" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Jeffrey Tan (VIP)
Hi moondaddy,

I am glad you figure it out.

ComboBox.SelectedItem will return a System.Object type object, it did not
has a row(0) member, so you can not do like this.

Also, if you do not specify ValueMember for ComboBox, combobox.selectedvalue
will return null object.

Hope this helps

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Reply to this message...
 
 
System.Object
System.Windows.Forms.ComboBox




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification