Для моего промежуточного уровня в Visual Basic .NET мне нужно показать свое мастерство в использовании различных общих элементов управления, и это включает в себя список и текстовое поле w/2 в качестве выхода. В основном мне нужно текстовое поле с двумя кнопками, чтобы исчезнуть, когда я использую listbox в качестве вывода и наоборот. изображение: код:Как сделать текстовое поле и/или список исчезнуть, когда это не нужно в Visual Basic .NET.
Public Class Form1
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
'Dim total As Integer
'Dim numone As Integer
'Dim numtwo As Integer
'
'numone = Val(TextBox1.Text)
'numtwo = Val(TextBox3.Text)
'total = numone + numtwo
'
'TextBox5.Text = total
End Sub
Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
'Dim total As Integer
'Dim numone As Integer
'Dim numtwo As Integer
'
'numone = Val(TextBox1.Text)
'numtwo = Val(TextBox3.Text)
'total = numone - numtwo
'
'TextBox5.Text = total
End Sub
Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged
'Dim total As Integer
'Dim numone As Integer
'Dim numtwo As Integer
'
'numone = Val(TextBox1.Text)
'numtwo = Val(TextBox3.Text)
'total = numone/numtwo
'TextBox5.Text = total
End Sub
Private Sub CheckBox4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox4.CheckedChanged
'Dim total As Integer
'Dim numone As Integer
'Dim numtwo As Integer
'
'numone = Val(TextBox1.Text)
'numtwo = Val(TextBox3.Text)
'total = numone * numtwo
'
'TextBox5.Text = total
End Sub
Private Sub CheckBox5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox5.CheckedChanged
'Dim FirstName As String
'Dim LastName As String
'Dim WholeName As String
'
'FirstName = TextBox2.Text
'LastName = TextBox4.Text
'
' WholeName = FirstName & " " & LastName
'
'TextBox5.Text = WholeName
End Sub
Private Sub CheckBox7_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox7.CheckedChanged
If CheckBox7.CheckState = 1 Then
ComboBox1.Items.Add("Homer Simpson")
ComboBox1.Items.Add("Marge Simpson")
ComboBox1.Items.Add("Bart Simpson")
ComboBox1.Items.Add("Lisa Simpson")
ComboBox1.Items.Add("Maggie Simpson")
'TextBox5.Text = Val(ComboBox1)
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If CheckBox1.CheckState = 1 Then
Dim total As Integer
Dim numone As Integer
Dim numtwo As Integer
numone = Val(TextBox1.Text)
numtwo = Val(TextBox3.Text)
total = numone + numtwo
TextBox5.Text = total
End If
If CheckBox2.CheckState = 1 Then
Dim total As Integer
Dim numone As Integer
Dim numtwo As Integer
numone = Val(TextBox1.Text)
numtwo = Val(TextBox3.Text)
total = numone - numtwo
TextBox5.Text = total
End If
If CheckBox3.CheckState = 1 Then
Dim total As Integer
Dim numone As Integer
Dim numtwo As Integer
numone = Val(TextBox1.Text)
numtwo = Val(TextBox3.Text)
numone = total/numtwo
TextBox5.Text = total
End If
If CheckBox4.CheckState = 1 Then
Dim total As Integer
Dim numone As Integer
Dim numtwo As Integer
numone = Val(TextBox1.Text)
numtwo = Val(TextBox3.Text)
total = numone * numtwo
TextBox5.Text = total
End If
If CheckBox5.CheckState = 1 Then
Dim FirstName As String
Dim LastName As String
Dim WholeName As String
FirstName = TextBox2.Text
LastName = TextBox4.Text
WholeName = FirstName & " " & LastName
TextBox5.Text = WholeName
End If
If CheckBox6.CheckState = 1 Then
With ListBox1
.Enabled = True 'if the listox is enable or disabled
.Sorted = True ' if you want ti list sorted
.BorderStyle = BorderStyle.Fixed3D ' the border style
.Visible = True
.ScrollAlwaysVisible = True 'presence of scroll all time
.MultiColumn = False 'add a new column if number of items reach max height
End With
ListBox1.Items.Add("Homer Simpson")
ListBox1.Items.Add("Marge Simpson")
ListBox1.Items.Add("Bart Simpson")
ListBox1.Items.Add("Lisa Simpson")
ListBox1.Items.Add("Maggie Simpson")
'ListBox1.Items.Add("allo1")
'ListBox1.Items.Add("allo2")
'ListBox1.Items.Add("allo3")
'ListBox1.Items.Add("allo4")
'ListBox1.Items.Add("allo5")
'ListBox1.Items.Add("allo1")
'ListBox1.Items.Add("allo2")
'ListBox1.Items.Add("allo3")
'ListBox1.Items.Add("allo4")
'ListBox1.Items.Add("allo5")
End If
If CheckBox7.CheckState = 1 Then
'ComboBox1.Items.Add("Homer Simpson")
'ComboBox1.Items.Add("Marge Simpson")
'ComboBox1.Items.Add("Bart Simpson")
'ComboBox1.Items.Add("Lisa Simpson")
'ComboBox1.Items.Add("Maggie Simpson")
TextBox5.Text = ComboBox1.Text
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox5.Clear()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
ListBox1.Items.Clear()
Me.ComboBox1.Items.Clear()
' text2.Clear()
' text1.Clear()
' text2.Clear()
ComboBox1.Items.Clear()
CheckBox1.Checked = False
CheckBox2.Checked = False
CheckBox3.Checked = False
CheckBox4.Checked = False
CheckBox5.Checked = False
CheckBox6.Checked = False
CheckBox7.Checked = False
End Sub
End Class
Что именно вы имеете в виду? Вы хотите скрыть Listbox, если вы введете что-то в текстовое поле? Затем обработайте событие «.TextChanged» текстового поля и «Listbox1.Visible = False» в обработчике. Вероятно, вы имеете в виду что-то другое, но это не ясно из вашего вопроса. Пожалуйста, объясните немного больше того, чего вы хотите достичь, и разместите более релевантные фрагменты кода. – Jens