I am done with designing the windows form::
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ComboBox2.Visible = False
Label2.Visible = False
ComboBox3.Visible = False
Label3.Visible = False
ComboBox4.Visible = False
Label4.Visible = False
ComboBox5.Visible = False
Label5.Visible = False
DateTimePicker1.Visible = False
End Sub
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
If (ComboBox1.Text = "BY-ELECTION") Then
ComboBox2.Visible = True
Label2.Visible = True
DateTimePicker1.Visible = False
ElseIf (ComboBox1.Text = "GENERAL ELECTION") Then
ComboBox2.Visible = False
Label2.Visible = False
ComboBox3.Visible = False
Label3.Visible = False
ComboBox4.Visible = False
Label4.Visible = False
ComboBox5.Visible = False
Label5.Visible = False
DateTimePicker1.Visible = True
End If
End Sub
Private Sub ComboBox4_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox4.SelectedIndexChanged
If ComboBox4.SelectedValue = "" And ComboBox2.Text = "MP" Then
DateTimePicker1.Visible = True
End If
If (ComboBox4.Text = "MVITA") And ComboBox2.Text = "MCA" Then
Label5.Visible = True
ComboBox5.Visible = True
ComboBox5.Items.Clear()
ComboBox5.Items.Add("MAJENGO")
ComboBox5.Items.Add("MAKADARA")
ComboBox5.Items.Add("SHIMANZI")
ComboBox5.Items.Add("TONONOKA")
ComboBox5.Items.Add("TUDOR")
DateTimePicker1.Visible = False
End If
End Sub
Private Sub ComboBox3_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox3.SelectedIndexChanged
If (ComboBox3.Text = "MOMBASA") And ComboBox2.Text = "MP" Or (ComboBox3.Text = "MOMBASA") And ComboBox2.Text = "MCA" Then
Label4.Visible = True
ComboBox4.Visible = True
ComboBox4.Items.Clear()
ComboBox4.Items.Add("CHANGAMWE")
ComboBox4.Items.Add("JOMVU")
ComboBox4.Items.Add("KISAUNI")
ComboBox4.Items.Add("LIKONI")
ComboBox4.Items.Add("MVITA")
ComboBox4.Items.Add("NYALI")
End If
End Sub
Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
If ComboBox2.Text = "GOVERNORSHIP" Or ComboBox2.Text = "SENATOR" Then
Label3.Visible = True
ComboBox3.Visible = True
Label5.Visible = False
ComboBox5.Visible = False
DateTimePicker1.Visible = True
ComboBox4.Visible = False
Label4.Visible = False
ElseIf ComboBox2.Text = "MP" Or ComboBox2.Text = "MCA" Then
Label3.Visible = True
ComboBox3.Visible = True
DateTimePicker1.Visible = False
Label6.Visible = False
ComboBox4.Visible = False
Label4.Visible = False
ComboBox5.Visible = False
Label5.Visible = False
End If
End Sub
Private Sub ComboBox5_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox5.SelectedIndexChanged
Label6.Visible = True
DateTimePicker1.Visible = True
End Sub
and i am stuck at the command button.
My windows form has 5 combobox with items assigned to them but in this illustration i am going to use one item for example:
- Combobox2 has item MCA
- Combobox3(labeled COUNTY) has item MOMBASA
- Combobox4(labeled CONSTITUENCY) has item MVITA
- Combobox5(labeled WARD) has item SHIMANZI
I want if i select item MCA in combobox2 and click the button GENERATE a table:
will be created and saved in the path C:UsersAdministratorDocuments
and populated in the following format
- cell A2 = item selected in combobox3
- cell B2= item selected in combobox4
- cell C2=item selected in combobox5
- cell H2 to be populated with random input be based on gender(male/female) and letters(ABCD only) in that order. ie cell H2= MALE,D
question from:
https://stackoverflow.com/questions/65871530/population-of-table-from-windows-form 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…