Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Pro Visual Basic 2005
|
Pro Visual Basic 2005 For advanced Visual Basic coders working in version 2005. Beginning-level questions will be redirected to other forums, including Beginning VB 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro Visual Basic 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 19th, 2007, 09:56 AM
Authorized User
 
Join Date: Oct 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to VBM2
Default Unbound combo box / listbox problem

Hi all!

Question... Can an unbound control in VB2005 receive ID values from a class?

For example...

-----------------
'this would populate the names of a class, but not pass in any ID numbers from the database
Dim RecordCol As RecordCollection = [ClassName].GetAllRecords
Dim i As Integer

For i = 0 To (RecordCol.Count - 1)
    Combobox1.Items.Add(RecordCol.Item(i).Name.ToStrin g)
Next i
-----------------

I realise I can use the datasource property, but I don't want to purely because I'm a mega "anti-databound" type developer. I also know that using the valuemember and selectedvalue properties may be of some use, but I can't figure out a way of doing it the way I am.

Using VB6 this was simply acheived by doing:

---------------
    Combo1.Additem("Item1")
    Combo1.ItemData(Combo1.NewIndex) = RecordSet("FieldName")
---------------

I've tried the beginners forum, but not had any answers (and it's a week old).

Hope someone can help...

Kind regards,

Craig
__________________
Kind regards,

Craig
 
Old February 19th, 2007, 10:11 AM
Authorized User
 
Join Date: Nov 2006
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ef1196
Default

Here is a post that may help:

http://www.mgbrown.com/PermaLink37.aspx




Best Regards,
Earl Francis
 
Old February 20th, 2007, 07:58 AM
Authorized User
 
Join Date: Oct 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to VBM2
Default

Thanks ef1196. Has helped!

I may just be in silly mode today or something, but I can't figure out (from the solution from the website provided) how to tell a (for example) combo box to go to a certain record by using this new class.

Basically once you read a record from the database that includes an id number, how do you make the combo box (that has been populated using this method) then go to the correct item within its list?

I've tried as much as I can think of... but I think I'm in silly mode today...

Cheers!

Kind regards,

Craig
 
Old March 13th, 2007, 11:04 AM
Registered User
 
Join Date: Mar 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

From my experience, if you have a load of controls, including your combo, connected to a datasource everything happens without any code. As your combo is disconnected it can't update anything else. Your other controls will have to be updated manually using a data row.

Personally I never use connected controls, I like to know my code is doing the job!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo box to display items from parent combo box Gini Visual Studio 2008 0 June 18th, 2008 12:30 AM
Combo box choice creating filtered combo box stevensj5 Access 11 September 13th, 2007 11:33 AM
filtering records on subform from an unbound combo jd_erd Access 3 February 12th, 2007 11:21 PM
Options in unbound combo box not saving? Badjoojoojen Access 17 April 2nd, 2005 05:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.