Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / September 2004

Tip: Looking for answers? Try searching our database.

Problem getting value from combobox and late binding

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
moondaddy - 10 Sep 2004 07:05 GMT
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

Signature

moondaddy@nospam.com

moondaddy - 10 Sep 2004 07:31 GMT
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.

> 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
[quoted text clipped - 13 lines]
>
> Thanks
Jeffrey Tan - 12 Sep 2004 14:38 GMT
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
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.