Click here to Skip to main content
15,885,435 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a window application form on vb.net
I have a combo box with 3 items list.
on selection of any one item ,it should active the respective user control on the form.

thanks

Improved que..?

I have a windows form with a combo box with three items and three users controls.
as i select 1 item from the combo box list, its respective user control should be active.
and rest two user controls will be inactive
Posted
Updated 29-Jan-13 0:28am
v2
Comments
CHill60 29-Jan-13 6:32am    
Still not quite a question - are you asking us how to write the code to do this? Have you tried anything yet? If so then post your code. If not then have a go first
CPallini 29-Jan-13 6:33am    
And your problem is?

1 solution

Hi,
Below code show how to activate / deactivate (Enable/disable) button based on the item selection in combobox.

VB
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        If (ComboBox1.SelectedIndex <> -1) Then
            If (ComboBox1.Text = "One") Then
                Button1.Enabled = True
                Button2.Enabled = False
                Button3.Enabled = False
            ElseIf (ComboBox1.Text = "Two") Then
                Button1.Enabled = False
                Button2.Enabled = True
                Button3.Enabled = False
            ElseIf (ComboBox1.Text = "Three") Then
                Button1.Enabled = False
                Button2.Enabled = False
                Button3.Enabled = True
            End If
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Button1.Enabled = False
        Button2.Enabled = False
        Button3.Enabled = False
    End Sub


Hope this helps for you!.

Best Regards
Muthuraja
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900