ComponentOne List for WinForms
In This Topic
    Tutorial 6 - Selecting Multiple Rows Using Bookmarks
    In This Topic

    In this tutorial, you will learn how to select and highlight records that satisfy specified criteria. A group of similar items is generally implemented as a collection in C1List. When manipulating a group of items in C1List, use techniques similar to those described here.

    1. Follow steps 1 through 4 of the Tutorial 1 - Binding C1List to a DataSet to create a project with a C1List control bound to a Data Set.
    2. Set Button1's Text property to Select and set Button2's Text property to Clear. The .NET design window and form should look like the following:
    3. We can easily select and deselect rows in C1List by manipulating the SelectedRowCollection. To select rows, place the following code in the Button1_Click event:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Dim i As Long    
      For i = 0 To Me.DsComposer.Composer.Rows.Count - 1    
          If Me.DsComposer.Composer.Rows(i).Item("Country") = "Germany" Then    
      </code><br/> Me.C1List1.SelectedIndices.Add(i)    
          End If    
      Next i
      

      To write code in C#

      C#
      Copy Code
      long i;    
      for ( i = 0; i <= this.DsComposer.Composer.Rows.Count - 1; i++)   
      {   
          if ( this.DsComposer.Composer.Rows[i] ["Country"] == "Germany" )   
          {    
       </code><br/>this.c1List1.SelectedIndices.Add(i);    
          }   
      }
      
    4. 4To deselect rows, place the following code in the Button2_Click event:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Me.C1List1.ClearSelected()
      

      To write code in C#

      C#
      Copy Code
      this.c1List1.ClearSelected();
      

    Run the program and observe the following:

    This concludes the tutorial.