0

嗨,我想在选择ComboBox中的项目时在RichTextbox中显示三列。我想显示相应的演员年份、电影名称和电影列制作的金额。这是我所拥有的:

Private Sub employeeComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles employeeComboBox.SelectedIndexChanged
    If employeeComboBox.SelectedItem Is "Sean Connery" Then
        historyTextBox.Text = ""
    ElseIf employeeComboBox.SelectedItem Is "George Lazenby" Then
        historyTextBox.Text = ""
    ElseIf employeeComboBox.SelectedItem Is "Roger Moore" Then
        historyTextBox.Text = ""
    ElseIf employeeComboBox.SelectedItem Is "Timothy Dalton" Then
        historyTextBox.Text = ""
    ElseIf employeeComboBox.SelectedItem Is "Pierce Brosnan" Then
        historyTextBox.Text = ""
    ElseIf employeeComboBox.SelectedItem Is "Daniel Craig" Then
        historyTextBox.Text = ""
    End If
End Sub
4

1 回答 1

1
RichTextBox1.Text = "Row1 Col1" & vbTab & " Row1 Col2" & vbTab & "Row1 Col3" & vbCrLf &
  "Row2 Col1" & vbTab & " Row2 Col2" & vbTab & "Row2 Col3"

但是,我建议您使用DataGridView控件而不是 RichTextBox,因此您可以单击列标题以按名称、年份等进行排序。

Dim dtb As New DataTable
dtb.Columns.Add("Year", GetType(String))
dtb.Columns.Add("Film", GetType(String))
dtb.Columns.Add("Actor", GetType(String))
dtb.Rows.Add("2001", "Film one", "Zac Black")
dtb.Rows.Add("2002", "Film two", "Young Green")
dtb.Rows.Add("2003", "Film three", "Xerxes Snifflehauser")
DataGridView1.AllowUserToAddRows = False
DataGridView1.AllowUserToDeleteRows = False
DataGridView1.DataSource = dtb
于 2012-10-16T01:15:42.233 回答