|
-
Jan 11th, 2021, 06:09 PM
#1
Thread Starter
Junior Member
-
Jan 11th, 2021, 06:23 PM
#2
Re: How do I use a combobox to make images and labels visible or hidden
You didn't explain what problems your having. But I'm in the mood for guessing so let me try to solve it without knowing what cbbox and Liverpool actually represent.
Code:
If cboxPod.Text = "Liverpool" Then
-
Jan 11th, 2021, 06:28 PM
#3
Thread Starter
Junior Member
Re: How do I use a combobox to make images and labels visible or hidden
cboxPod is the ComoBox
Basically I want it so if I select the "Liverpool" item in the combobox, lblLiverpoolPod, PictureBoxLiverpool, and txtFeaturesLiverpool will show and vice versa for the "Manchester" item and the "London" item.
-
Jan 11th, 2021, 08:33 PM
#4
Re: [RESOLVED] How do I use a combobox to make images and labels visible or hidden
Because you have several controls that you're wanting to toggle the visibility on, I would suggest storing a Dictionary where the Key would represent the item in the ComboBox and the Value would represent a collection of the controls that should be visible.
Take a look at this example:
Code:
Public Class Form1
Private ReadOnly _visibilityControls As Dictionary(Of String, Control())
Sub New()
_visibilityControls = New Dictionary(Of String, Control()) From {
{"Liverpool", {lblLiverpoolPod, PictureBoxLiverpool, txtFeaturesLiverpool}},
{"Manchester", {lblManchesterPod, PictureBoxManchester, txtFeaturesManchester}},
{"London", {lblLondonPod, PictureBoxLondon, txtFeaturesLondon}}
}
End Sub
Private Sub cboxPod_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboxPod.SelectedIndexChanged
For Each pair In _visibilityControls
For Each futbolControl In pair.Value
futbolControl.Visible = (cboxPod.Text = pair.Key)
Next
Next
End Sub
End Class
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|