Solved

Button click no function after ComboBox SelectedItem Changed

Posted on 2016-09-19
10
24 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
  • 5
  • 4
10 Comments
 
LVL 49

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 49

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
 

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 49

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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 49

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 49

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SQL Server 2008 Error 7 54
Vb.Net Menu 1 22
Crystal Report for VS2013 17 40
VB.Net - ReportViewer Windows Form many reports 2 5
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now