ComponentOne List for WinForms
In This Topic
    Displaying Multiple Columns in C1Combo
    In This Topic

    You can display multiple columns in the C1Combo control through the Close event of the C1Combo to include multiple column values in the display area of the C1Combo control.

    1. Bind the DataSet to the C1Combo control. For more information on how to bind to a C1Combo control, see Tutorial 2 - Binding C1Combo to a DataSet.
    2. Set the columns you would like visible using the C1DisplayColumn Collection Editor. For more information on how to make columns visible, see Hiding or Displaying a Column. For this example, hide all columns except for Company.
    3. Add the following Close event for C1Combo:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Dim _textChanging As Boolean = False
      
      Private Sub C1Combo1_Close(ByVal sender As Object, ByVal e As System.EventArgs) Handles C1Combo1.Close
          Dim index As Integer = Me.C1Combo1.SelectedIndex()
          If (index >= 0) Then
              _textChanging = True
              Me.C1Combo1.Text = (Me.C1Combo1.Columns("FirstName").CellText(index) + (" " + (Me.C1Combo1.Columns("LastName").CellText(index) + (" at " +
      Me.C1Combo1.Columns("Company").CellText(index)))))
              _textChanging = False
          End If
      End Sub
      
      Private Sub C1Combo1_SelChange(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)
          e.Cancel = _textChanging
      
      End Sub 
      

      To write code in C#

      C#
      Copy Code
      bool _textChanging = false;
      
      private void c1Combo1_Close(object sender, System.EventArgs e)
      {
          int index = this.c1Combo1.SelectedIndex;
          if (index >= 0)
          {
              _textChanging = true;
              this.c1Combo1.Text = this.c1Combo1.Columns["FirstName"].CellText(index) + " " + this.c1Combo1.Columns["LastName"].CellText(index) + " at " +
      this.c1Combo1.Columns["Company"].CellText(index);
              _textChanging = false;
          }
      }
      
      private void c1Combo1_SelChange(object sender, System.ComponentModel.CancelEventArgs e)
      {
          e.Cancel = _textChanging;
      }
      

    This topic illustrates the following:

    When a company is selected from the list, the first and last name of the contact and the company appears in the C1Combo control.