Solved

Button click no function after ComboBox SelectedItem Changed

Posted on 2016-09-19
10
38 Views
Last Modified: 2016-09-21
Without clicking on ComboBox, the button works well. But after i have click on ComboBox SelectdItemChanged, the Button doesn't function. For your Info i am not train on VB and i just learn it from article and try it myself. Please advise.
0
Comment
Question by:Lim HC
[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
  • 5
  • 4
10 Comments
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 41805828
do you have codes can share with us? we are not too sure what you intend to do without looking into it.
0
 

Expert Comment

by:Lim HC
ID: 41805852
Without clicking on ComboBox, the button works well. But after i have click on ComboBox SelectdItemChanged, the Button doesn't function. For your Info i am not train on VB and i just learn it from article and try it myself. Please advise.
 Below are code

Imports System.Windows.Forms


Public Class Form1
    Inherits System.Windows.Forms.Form

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Me.Hide()
    End Sub
    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        Dim result As DialogResult = MessageBox.Show("Are you sure you want to Proceed?", "Confirmation?", MessageBoxButtons.YesNo)
        If result = DialogResult.Yes Then
            Form2.Show()
        ElseIf result = Windows.Forms.DialogResult.No Then
            Me.Show()
        End If
    End Sub

    Private Sub TblDefectBindingNavigatorSaveItem_Click(sender As System.Object, e As System.EventArgs)
        Me.Validate()
        Me.TblDefectBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.Database1DataSet)

    End Sub
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'Database1DataSet.tblDefect' table. You can move, or remove it, as needed.
        Me.TblDefectTableAdapter.Fill(Me.Database1DataSet.tblDefect)

    End Sub
   
    Private Sub Defect_ItemComboBox_SelectedItemChanged(sender As System.Object, e As System.EventArgs) Handles Defect_ItemComboBox.SelectedIndexChanged
        PictureBox1.Image = Nothing
        PictureBox2.Image = Nothing
        PictureBox3.Image = Nothing
        PictureBox4.Image = Nothing
        PictureBox5.Image = Nothing
        PictureBox6.Image = Nothing
        PictureBox7.Image = Nothing
        PictureBox8.Image = Nothing
        If Defect_ItemComboBox.Text = "Cold Solder" Then
            PictureBox1.Image = My.Resources.Cold_Solder1_1
        End If
        If Defect_ItemComboBox.Text = "De-Wetting" Then
            PictureBox1.Image = My.Resources.De_Wetting1_1
            PictureBox2.Image = My.Resources.De_Wetting1_2
        End If
        If Defect_ItemComboBox.Text = "Solder Bridge1" Then
            PictureBox1.Image = My.Resources.bridge1_1
        End If
        If Defect_ItemComboBox.Text = "Solder Bridge2" Then
            PictureBox1.Image = My.Resources.bridge2_1
        End If
        If Defect_ItemComboBox.Text = "Solder Bridge3" Then
            PictureBox1.Image = My.Resources.bridge3_1
            PictureBox5.Image = My.Resources.Prevent_bridge3_1
            PictureBox6.Image = My.Resources.Prevent_bridge3_2
        End If
        If Defect_ItemComboBox.Text = "Solder Bridge4" Then
            PictureBox1.Image = My.Resources.bridge4_1
            PictureBox2.Image = My.Resources.bridge4_2
            PictureBox5.Image = My.Resources.Prevent_bridge4_1
        End If
        If Defect_ItemComboBox.Text = "Solder Bridge5" Then
            PictureBox1.Image = My.Resources.bridge5_1
            PictureBox5.Image = My.Resources.Prevent_bridge5_1
            PictureBox6.Image = My.Resources.Prevent_bridge5_2
        End If
        If Defect_ItemComboBox.Text = "Disturbed Solder" Then
            PictureBox1.Image = My.Resources.Disturbed_Solder1_1
        End If
        If Defect_ItemComboBox.Text = "Excess Solder" Then
            PictureBox1.Image = My.Resources.Excess_Solder1_1
        End If
        If Defect_ItemComboBox.Text = "Insufficient Fill" Then
            PictureBox1.Image = My.Resources.Fill1_1
            PictureBox2.Image = My.Resources.Fill1_2
            PictureBox5.Image = My.Resources.Prevent_fill1_1
        End If
        If Defect_ItemComboBox.Text = "Flux Residue" Then
            PictureBox1.Image = My.Resources.Flux_Residue1_1
        End If
        If Defect_ItemComboBox.Text = "Grainy Joints" Then
            PictureBox1.Image = My.Resources.Grainy1_1
            PictureBox2.Image = My.Resources.Grainy1_2
            PictureBox5.Image = My.Resources.Prevent_grainy1_1
            PictureBox6.Image = My.Resources.Prevent_grainy1_2
        End If
        If Defect_ItemComboBox.Text = "Icicle (Projection or Horn)" Then
            PictureBox1.Image = My.Resources.Icicle1_1
            PictureBox2.Image = My.Resources.Icicle1_2
        End If
        If Defect_ItemComboBox.Text = "Insufficient Solder" Then
            PictureBox1.Image = My.Resources.Insufficient_solder1
            PictureBox2.Image = My.Resources.Insufficient_solder1_2
            PictureBox5.Image = My.Resources.Prevent_insufficient1_1
        End If
        If Defect_ItemComboBox.Text = "Non Wetting" Then
            PictureBox1.Image = My.Resources.Non_Wetting1_1
            PictureBox2.Image = My.Resources.Non_Wetting1_2
        End If
        If Defect_ItemComboBox.Text = "Pin hole1" Then
            PictureBox1.Image = My.Resources.Pin_hole1_1
            PictureBox2.Image = My.Resources.Pin_hole1_2
        End If
        If Defect_ItemComboBox.Text = "Pin hole2" Then
            PictureBox1.Image = My.Resources.Pin_hole2_1
            PictureBox2.Image = My.Resources.Pin_hole2_2
        End If
        If Defect_ItemComboBox.Text = "Pin hole3" Then
            PictureBox1.Image = My.Resources.Pin_hole3_1
            PictureBox2.Image = My.Resources.Pin_hole3_2
        End If
        If Defect_ItemComboBox.Text = "Random Solder Ball" Then
            PictureBox1.Image = My.Resources.SB1_1
            PictureBox2.Image = My.Resources.SB1_2
            PictureBox5.Image = My.Resources.Prevent_SB1_1
        End If
        If Defect_ItemComboBox.Text = "Chip side ball" Then
            PictureBox1.Image = My.Resources.Side_ball1_1
            PictureBox5.Image = My.Resources.Prevent_side_ball1_1
            PictureBox6.Image = My.Resources.Prevent_side_ball1_2
        End If
        If Defect_ItemComboBox.Text = "Solder Skip1" Then
            PictureBox1.Image = My.Resources.Skip1_1
            PictureBox2.Image = My.Resources.Skip1_2
            PictureBox3.Image = My.Resources.Skip1_3
            PictureBox4.Image = My.Resources.Skip1_4
            PictureBox5.Image = My.Resources.Prevent_skip1_1
            PictureBox6.Image = My.Resources.Prevent_skip1_2
            PictureBox7.Image = My.Resources.Prevent_skip1_3
        End If
        If Defect_ItemComboBox.Text = "Solder Skip2" Then
            PictureBox1.Image = My.Resources.Skip2_1
            PictureBox2.Image = My.Resources.Skip2_2
            PictureBox5.Image = My.Resources.Prevent_skip2_1
        End If
        If Defect_ItemComboBox.Text = "Spattering1" Then
            PictureBox1.Image = My.Resources.Spatter1_1
        End If
        If Defect_ItemComboBox.Text = "Spattering2" Then
            PictureBox1.Image = My.Resources.Spatter2_1
            PictureBox2.Image = My.Resources.Spatter2_2
            PictureBox5.Image = My.Resources.Prevent_spatter2_1
        End If
        If Defect_ItemComboBox.Text = "Tombstoning" Then
            PictureBox1.Image = My.Resources.Ts1_1
            PictureBox2.Image = My.Resources.Ts1_2
            PictureBox5.Image = My.Resources.Prevent_ts1_1
            PictureBox6.Image = My.Resources.Prevent_ts1_2
            PictureBox7.Image = My.Resources.Prevent_ts1_3
        End If
        If Defect_ItemComboBox.Text = "Voids" Then
            PictureBox1.Image = My.Resources.Void1_1
            PictureBox2.Image = My.Resources.Void1_2
            PictureBox3.Image = My.Resources.Void1_3
            PictureBox5.Image = My.Resources.Prevent_void1_1
            PictureBox6.Image = My.Resources.Prevent_void1_2
            PictureBox7.Image = My.Resources.Prevent_void1_3
            PictureBox8.Image = My.Resources.Prevent_void1_4
        End If
        If Defect_ItemComboBox.Text = "Webbing" Then
            PictureBox1.Image = My.Resources.Webbing1_1
        End If
    End Sub
End Class
0
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 41806058
pls see if the explanation below is correct?

you got Defect_ItemComboBox which will change the image of pictureboxes?
you got 2 buttons in your form:
-Button1 will hide your form
-Button2 will prompt a dialog box with selection of Yes, No. If user selected Yes, it will show Form 2.

>>the Button doesn't function
can you explain this a bit further?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Lim HC
ID: 41806076
Hi Ryan,
Before i click on Combobox to select item, the button is functioning as i assign. but after i click on Combobox to select item, the both button does not function.
0
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 41806100
the 2 buttons' Click events are pretty simple, i don't think if you adding the SelectedItemChanged event of comboxbox will affect how these buttons behaved.

do you have a sample project can upload here? we will try to diagnose it.
0
 

Author Comment

by:Lim HC
ID: 41806105
Hi Expert,
Below are the program which i used. please advise

Imports System.Windows.Forms

Public Class Form1
    Inherits System.Windows.Forms.Form

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Me.Hide()
    End Sub
    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        Dim result As DialogResult = MessageBox.Show("Are you sure you want to Proceed?", "Confirmation?", MessageBoxButtons.YesNo)
        If result = DialogResult.Yes Then
            Form2.Show()
        ElseIf result = Windows.Forms.DialogResult.No Then
            Me.Show()
        End If
    End Sub

    Private Sub TblDefectBindingNavigatorSaveItem_Click(sender As System.Object, e As System.EventArgs)
        Me.Validate()
        Me.TblDefectBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.Database1DataSet)

    End Sub
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'Database1DataSet.tblDefect' table. You can move, or remove it, as needed.
        Me.TblDefectTableAdapter.Fill(Me.Database1DataSet.tblDefect)

    End Sub
   
    Private Sub Defect_ItemComboBox_SelectedItemChanged(sender As System.Object, e As System.EventArgs) Handles Defect_ItemComboBox.SelectedIndexChanged
        PictureBox1.Image = Nothing
        PictureBox2.Image = Nothing
        PictureBox3.Image = Nothing
        PictureBox4.Image = Nothing
        PictureBox5.Image = Nothing
        PictureBox6.Image = Nothing
        PictureBox7.Image = Nothing
        PictureBox8.Image = Nothing
        If Defect_ItemComboBox.Text = "Cold Solder" Then
            PictureBox1.Image = My.Resources.Cold_Solder1_1
        End If
        If Defect_ItemComboBox.Text = "De-Wetting" Then
            PictureBox1.Image = My.Resources.De_Wetting1_1
            PictureBox2.Image = My.Resources.De_Wetting1_2
        End If
        If Defect_ItemComboBox.Text = "Solder Bridge1" Then
            PictureBox1.Image = My.Resources.bridge1_1
        End If
        If Defect_ItemComboBox.Text = "Solder Bridge2" Then
            PictureBox1.Image = My.Resources.bridge2_1
        End If
        If Defect_ItemComboBox.Text = "Solder Bridge3" Then
            PictureBox1.Image = My.Resources.bridge3_1
            PictureBox5.Image = My.Resources.Prevent_bridge3_1
            PictureBox6.Image = My.Resources.Prevent_bridge3_2
        End If
        If Defect_ItemComboBox.Text = "Solder Bridge4" Then
            PictureBox1.Image = My.Resources.bridge4_1
            PictureBox2.Image = My.Resources.bridge4_2
            PictureBox5.Image = My.Resources.Prevent_bridge4_1
        End If
        If Defect_ItemComboBox.Text = "Solder Bridge5" Then
            PictureBox1.Image = My.Resources.bridge5_1
            PictureBox5.Image = My.Resources.Prevent_bridge5_1
            PictureBox6.Image = My.Resources.Prevent_bridge5_2
        End If
        If Defect_ItemComboBox.Text = "Disturbed Solder" Then
            PictureBox1.Image = My.Resources.Disturbed_Solder1_1
        End If
        If Defect_ItemComboBox.Text = "Excess Solder" Then
            PictureBox1.Image = My.Resources.Excess_Solder1_1
        End If
        If Defect_ItemComboBox.Text = "Insufficient Fill" Then
            PictureBox1.Image = My.Resources.Fill1_1
            PictureBox2.Image = My.Resources.Fill1_2
            PictureBox5.Image = My.Resources.Prevent_fill1_1
        End If
        If Defect_ItemComboBox.Text = "Flux Residue" Then
            PictureBox1.Image = My.Resources.Flux_Residue1_1
        End If
        If Defect_ItemComboBox.Text = "Grainy Joints" Then
            PictureBox1.Image = My.Resources.Grainy1_1
            PictureBox2.Image = My.Resources.Grainy1_2
            PictureBox5.Image = My.Resources.Prevent_grainy1_1
            PictureBox6.Image = My.Resources.Prevent_grainy1_2
        End If
        If Defect_ItemComboBox.Text = "Icicle (Projection or Horn)" Then
            PictureBox1.Image = My.Resources.Icicle1_1
            PictureBox2.Image = My.Resources.Icicle1_2
        End If
        If Defect_ItemComboBox.Text = "Insufficient Solder" Then
            PictureBox1.Image = My.Resources.Insufficient_solder1
            PictureBox2.Image = My.Resources.Insufficient_solder1_2
            PictureBox5.Image = My.Resources.Prevent_insufficient1_1
        End If
        If Defect_ItemComboBox.Text = "Non Wetting" Then
            PictureBox1.Image = My.Resources.Non_Wetting1_1
            PictureBox2.Image = My.Resources.Non_Wetting1_2
        End If
        If Defect_ItemComboBox.Text = "Pin hole1" Then
            PictureBox1.Image = My.Resources.Pin_hole1_1
            PictureBox2.Image = My.Resources.Pin_hole1_2
        End If
        If Defect_ItemComboBox.Text = "Pin hole2" Then
            PictureBox1.Image = My.Resources.Pin_hole2_1
            PictureBox2.Image = My.Resources.Pin_hole2_2
        End If
        If Defect_ItemComboBox.Text = "Pin hole3" Then
            PictureBox1.Image = My.Resources.Pin_hole3_1
            PictureBox2.Image = My.Resources.Pin_hole3_2
        End If
        If Defect_ItemComboBox.Text = "Random Solder Ball" Then
            PictureBox1.Image = My.Resources.SB1_1
            PictureBox2.Image = My.Resources.SB1_2
            PictureBox5.Image = My.Resources.Prevent_SB1_1
        End If
        If Defect_ItemComboBox.Text = "Chip side ball" Then
            PictureBox1.Image = My.Resources.Side_ball1_1
            PictureBox5.Image = My.Resources.Prevent_side_ball1_1
            PictureBox6.Image = My.Resources.Prevent_side_ball1_2
        End If
        If Defect_ItemComboBox.Text = "Solder Skip1" Then
            PictureBox1.Image = My.Resources.Skip1_1
            PictureBox2.Image = My.Resources.Skip1_2
            PictureBox3.Image = My.Resources.Skip1_3
            PictureBox4.Image = My.Resources.Skip1_4
            PictureBox5.Image = My.Resources.Prevent_skip1_1
            PictureBox6.Image = My.Resources.Prevent_skip1_2
            PictureBox7.Image = My.Resources.Prevent_skip1_3
        End If
        If Defect_ItemComboBox.Text = "Solder Skip2" Then
            PictureBox1.Image = My.Resources.Skip2_1
            PictureBox2.Image = My.Resources.Skip2_2
            PictureBox5.Image = My.Resources.Prevent_skip2_1
        End If
        If Defect_ItemComboBox.Text = "Spattering1" Then
            PictureBox1.Image = My.Resources.Spatter1_1
        End If
        If Defect_ItemComboBox.Text = "Spattering2" Then
            PictureBox1.Image = My.Resources.Spatter2_1
            PictureBox2.Image = My.Resources.Spatter2_2
            PictureBox5.Image = My.Resources.Prevent_spatter2_1
        End If
        If Defect_ItemComboBox.Text = "Tombstoning" Then
            PictureBox1.Image = My.Resources.Ts1_1
            PictureBox2.Image = My.Resources.Ts1_2
            PictureBox5.Image = My.Resources.Prevent_ts1_1
            PictureBox6.Image = My.Resources.Prevent_ts1_2
            PictureBox7.Image = My.Resources.Prevent_ts1_3
        End If
        If Defect_ItemComboBox.Text = "Voids" Then
            PictureBox1.Image = My.Resources.Void1_1
            PictureBox2.Image = My.Resources.Void1_2
            PictureBox3.Image = My.Resources.Void1_3
            PictureBox5.Image = My.Resources.Prevent_void1_1
            PictureBox6.Image = My.Resources.Prevent_void1_2
            PictureBox7.Image = My.Resources.Prevent_void1_3
            PictureBox8.Image = My.Resources.Prevent_void1_4
        End If
        If Defect_ItemComboBox.Text = "Webbing" Then
            PictureBox1.Image = My.Resources.Webbing1_1
        End If
    End Sub
End Class
Project2.vbproj
0
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 41806224
hi,

.vbproj is not good enough... what i mean is the full proj files.

is it possible to upload it? You can zip and upload the project files.

it's quite impossible for us to rebuild a project just to simulate your issue.
0
 

Author Comment

by:Lim HC
ID: 41807916
Hi expert,
 Sorry, i will upload the folder. Hope it will help to solve my problem. Thank you.
Project2.zip
0
 
LVL 51

Accepted Solution

by:
Ryan Chong earned 500 total points
ID: 41808090
something wrong with your initial binding i guess?

I resolved the issue by rebinding the controls in your form.

check this out.
https://dl.dropboxusercontent.com/u/39360237/Project2_b.zip
(I was not able to upload via EE)
0
 

Author Closing Comment

by:Lim HC
ID: 41808171
Thank you very much Ryan
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP/VB email question 4 63
YouTube API get the Video Tags - vb.net 7 33
How can I add google maps in vb.net. 2 22
Broken .resx file generating errors 18 26
This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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