?
Solved

Populate parent dropdownbox based on child dropdownbox.

Posted on 2006-05-17
3
Medium Priority
?
240 Views
Last Modified: 2010-04-23
I have two dropdownboxes.

One has the following possibles values:
cboLegacySystem is the first dropdownbox:
AMAPS
PIOS
PX
IMS
AMPS

Now if the user selects AMAPS or PIOS then the second dropdownbox should be enabled
with the following values:
cboLegacySubSystem is the second dropdownbox:
Finance
Engineering
Manufacturing

Otherwise disable the second dropdownbox.

This is what I have so far:

Private Sub cboLegacySystem_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboLegacySystem.SelectedIndexChanged
        If ((cboLegacySystem.SelectedValue = 0) Or (cboLegacySystem.SelectedValue = 1)) Then
            ' Populate cboLegacySubSystem dropdownbox
            ' Enable cboLegacySubSystem dropdownbox
            cboLegacySubSystem.Enabled = True
            ' First Value will be Finance
            ' Second Value will be Engineering
            ' Third Value will be Manufacturing
        Else
            ' Disable cboLegacySubSystem dropdownbox
            cboLegacySubSystem.Enabled = False
        End If

    End Sub

    Private Sub cboLegacySubSystem_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboLegacySubSystem.SelectedIndexChanged

    End Sub

How should I do this?

Note when I populated the first dropdownbox I used the items and just add the values where it says (collections)

0
Comment
Question by:mathieu_cupryk
  • 2
3 Comments
 
LVL 34

Accepted Solution

by:
Brian Crowe earned 2000 total points
ID: 16704764
You should only populate cboLegacySubSystem dropdownbox once.  To prevent a value from being displayed after it is disabled set the selectedindex = -1


private sub myform_load(...) handles mybase.load
    ...
   'you could also choose to do this at design time
   with cbolegacysubsystem.items
      .add("Finance")
      .add("Engineering")
      .add("Manufacturing")
   end with
   ...
end sub

Private Sub cboLegacySystem_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboLegacySystem.SelectedIndexChanged
        If ((cboLegacySystem.SelectedValue = 0) Or (cboLegacySystem.SelectedValue = 1)) Then
            ' Enable cboLegacySubSystem dropdownbox
            cboLegacySubSystem.Enabled = True
            cbolegacysubsystem.selectedindex = 0
        Else
            ' Disable cboLegacySubSystem dropdownbox
            cbolegacysubsystem.selectedindex = -1
            cboLegacySubSystem.Enabled = False
        End If
    End Sub
0
 

Author Comment

by:mathieu_cupryk
ID: 16708089
Is it better to do?

with cbolegacysubsystem.items
      .add("Finance")
      .add("Engineering")
      .add("Manufacturing")
 end with

with the properties  = > Items = > Collections

and add the following manually.



0
 

Author Comment

by:mathieu_cupryk
ID: 16708129
Good job!!!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Integration Management Part 2
Loops Section Overview

839 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