TRzListBox Add Item to Group

Viewing 2 reply threads
  • Author
    Posts
    • #2275
      Barry Wood
      Participant

        Hi

        I have a TRzListBox setup with 2 headings: ‘Players’ and ‘Reserves’. During the application a User can add a new Player or Reserve.

        How do I add this new player to the ‘Players’ section? When I simply clList.Add( cNewName ) it goes to the bottom of the list.

      • #2279
        Ray Konopka
        Keymaster

          Hi Barry,

          You can use the AddItemToGroup method. For example, the following code adds a couple groups and items to the list. Then in the button click event handler, a new player is added to the first group. Changing the first parameter to a 1 will add Ian to the Reserves group.

          Ray

          procedure TForm8.FormCreate(Sender: TObject);
          begin
            RzListBox1.ShowGroups := True;
            RzListBox1.AddGroup( 'Players' );
            RzListBox1.Add( 'Anthony Rizzo' );
            RzListBox1.Add( 'Kris Bryant' );
            RzListBox1.Add( 'Javier Baez' );
            RzListBox1.AddGroup( 'Reserves' );
            RzListBox1.Add( 'Albert Almora Jr.' );
          end;
          
          procedure TForm8.RzButton1Click(Sender: TObject);
          begin
            RzListBox1.AddItemToGroup( 0, 'Ian Happ' );
          end;
        • #2280
          Barry Wood
          Participant

            Ray,

            Many thanks, as ever. I’m building up a list of ‘simple’ examples of how to use your controls ‘properly’, so one day I won’t need to ask you 🙂

        Viewing 2 reply threads
        • You must be logged in to reply to this topic.