Solved

i have problem with comboboxes

Posted on 2004-10-18
4
158 Views
Last Modified: 2010-04-23
Dear Experts,

i need a solution to the above problem.
I have two combobox the first combobox called Periphery and the second called county.
I want to do this : When i select a specified periphery from the first combobox i want the second combobox to give the specified county which belongs to the periphery..

the periphery and county get the fields from the tables from the database..
Please i need help...
0
Comment
Question by:dakanali
[X]
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
4 Comments
 
LVL 10

Accepted Solution

by:
123654789987 earned 25 total points
ID: 12337216
U can see the following link. It shows the relationship between a combobox and a listbox. U can implement the same with two comboboxes

http://codeproject.com/cs/miscctrl/valuemembersample.asp
0
 
LVL 19

Assisted Solution

by:arif_eqbal
arif_eqbal earned 25 total points
ID: 12337321
On SelectedIndexChanged of first ComboBox write the code to populate the other Combo


    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged


        Dim DR As OleDbDataReader
        Dim Cn As OleDbConnection = New OleDbConnection(YourConStr)
        Cn.Open()
        Dim Cmd As OleDbCommand = New OleDbCommand("Select YourCol From Yourtable Where AnotherCol='" & ComboBox1.Text & "'", Cn)
        DR = Cmd.ExecuteReader
        Do While DR.Read
            ComboBox2.Items.Add(DR(0))
         Loop

        DR.Close()
        Cn.Close()

End Sub


However this will require a roundtrip to the dataBase so you can as well store all data in a dataTable and locally populate the combobox

0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

751 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