×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Get Dataview Name From Array of Dataviews

Get Dataview Name From Array of Dataviews

Get Dataview Name From Array of Dataviews

(OP)
I have an array of data views constructed like this where the three data views have already been created.

CODE

dvList(0) = CompanyMasterView
dvList(1) = LeaseTypeView
dvList(2) = GroupView 
I'm using this array to assign the data source for combo boxes added at run time. Right now I'm using the array position (DataSourceNbr1 = 0,1,2) stored in my table to assign the data source. DisplayMember1 & ValueMember1 are also stored in my table.

CODE

PnlCombo.cboBox1.DisplayMember = DisplayMember1
PnlCombo.cboBox1.ValueMember = ValueMember1
PnlCombo.cboBox1.DataSource = dvList(DataSourceNbr1) 
I would like to just use the data view name I have stored in the table to find the correct index (0,1,2) in dvList, but I can't seem to find a way to get the data view name from the array dvList. Is there a way to do this?

Auguy
Sylvania/Toledo Ohio

RE: Get Dataview Name From Array of Dataviews

To do this, use a Collection instead of an Array.

CODE

Dim dvColl As Collection

dvColl = New Collection

dvColl.Add(CompanyMasterView, "Key 1")
dvColl.Add(LeaseTypeView, "Key 2")
dvColl.Add(GroupView, "Key 3")

PnlCombo.cboBox1.DisplayMember = DisplayMember1
PnlCombo.cboBox1.ValueMember = ValueMember1
PnlCombo.cboBox1.DataSource = dvColl("Key 1") 

As the code shows, Collections have a value and a key, and you can reference the value via the key, which is exactly what you want. You can use the DataView's name as the Key.

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!

RE: Get Dataview Name From Array of Dataviews

(OP)
Thanks! That will help a lot. BTW, this question is a follow up on another question you answered a few years ago. thread796-1691914: ListBox/ComboBox Dynamic Datasource I finally had time to got it working and this final piece will complete the code. Thanks again!

Auguy
Sylvania/Toledo Ohio

RE: Get Dataview Name From Array of Dataviews

(OP)
Thanks Jebenson, just finished the code using the collection, works perfectly. Thinking about where else I can use collections

Auguy
Sylvania/Toledo Ohio

RE: Get Dataview Name From Array of Dataviews

Awesome!

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close