Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How can one ComboBox's items be determined by another?

Posted on 2016-11-12
9
32 Views
Last Modified: 2016-11-14
Good day everyone, I don't have any code as yet to support my question, as I'm at this stage merely searching for direction.
I'm trying to figure out if / how can one ComboBox's items be determined by another, but without creating a Class to do the filter... most of the Threads and reading I've done thus far points in this direction ( that you do need it)
I've however been challenged to do it with out....does anyone know if this is a possibility?

thanks
Fadiel
0
Comment
Question by:fadiel ras
9 Comments
 
LVL 28

Expert Comment

by:Pawan Kumar
ID: 41885260
Are you talking about cascading parameters ?

E.g. State and Country , Based on country we shall fill States ?
0
 
LVL 84

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 125 total points
ID: 41885295
I use the SelectedIndexChange event of the combo to fill the dependent combo. For example, if I have a combo where the user selects a Car Make (cbMake), and I want to fill a combo where they can select the Car Model (cbModel), I'd do something like this in the SelectedIndexChange event of cbMake:

Using con As New SQLConnection(ConnectionString)
  con.Open
  Using cmd As New SQLCommand
    cmd.Connection = con
    cmd.CommandText = "SELECT ID, Model FROM tModels WHERE MakeID=" & cbMake.SelectedValue
    Dim dt As New Datatable
    dt.Load (cmd.ExecuteReader)
    With cbMake
      .DataSource = dt
      .DisplayMember = "Model"
      .ValueMember = "ID"
    End With
  End Using
End Using

Open in new window

0
 
LVL 28

Accepted Solution

by:
Pawan Kumar earned 250 total points
ID: 41885308
If you need cascading effect use below-

1. You have to fill the parent combo box. and based on the default value to parent combo box fill the child combo box.
2. Now when the end user changes the value of the parent combo box , fill the child combo box again.

You can use below URL for the entire steps. <<This url uses the example of Country and states>>
http://csharpdotnetfreak.blogspot.com/2012/07/cascading-combobox-in-winforms-windows-forms.html

Hope it helps!!
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 125 total points
ID: 41885390
0
 

Author Comment

by:fadiel ras
ID: 41885802
thanks Gents, I'll give your suggestion a try asap this morning!

>>Are you talking about cascading parameters ?
>>E.g. State and Country , Based on country we shall fill States ?

yes, 100% correct I was referring to cascading parameters

I'll feedback to the forum - thank you
0
 
LVL 28

Expert Comment

by:Pawan Kumar
ID: 41885806
Great ! Welcome.

Good luck !
0
 

Author Comment

by:fadiel ras
ID: 41885917
Hi there,
if my requirement changed to the Dropdown being within a data grid view and NOT a ComboBox do I post a new question?
or could the ComboBox solutions still work / be amended?

thank you
0
 
LVL 28

Expert Comment

by:Pawan Kumar
ID: 41885943
Yes that's a completely new question. I think you should post a new question for that.

Thank you!

Regards,
Pawan
0
 

Author Closing Comment

by:fadiel ras
ID: 41885961
Thanks Pawan, Scott and Eric
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question