0

こんにちは、コンボボックスのアイテムが選択されたときに、リッチテキストボックスに 3 つの列を表示したいと考えています。対応する俳優の年、映画名、および映画の列から作成された金額を表示したいと考えています。ここに私が持っているものがあります:

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"

ただし、DataGridViewRichTextBoxの代わりにコントロールを使用することをお勧めします。これにより、列見出しをクリックして、名前や年などで並べ替えることができます。

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 に答える