Checklistbox - how to pass a checklisbox to a function in Delphi

Asked

Viewed 90 times

0

I need to create a function where I pass to the function a Checklistbox and this function will store in a variable the values of the checklistbox.

function PegaDescricao(checklistbox .......... ) : String;                                                                          
var i, cont, descricao : Integer;  
begin
  cont := 0;                                   
  for i:=0 to checkListBox.Items.Count-1 do                 
  begin
    if cont = 0 then
    begin  
      cont := contad +1;                                                                                                      
      descricao:=copy(checkListBox.Items.Strings[i],1,Length(checkListBox.Items.Strings[i])-4);                            
    end
    else
      descricao:=descricao+', '+copy(checkListBox.Items.Strings[i],1,Length(checkListBox.Items.Strings[i])-4);  
  end;  
end;  

1 answer

3

Like any Delphi parameter, you need to declare your type. All Delphi components are objects, so just pass the name of the class referring to the object along with the parameter.

function PegaDescricao(checklistbox: TCheckListBox): String;
  • With this tip the problem was solved, only correcting in place of the Tckecklistbox parameter type I had to use the Tfrxchecklistboxcontrol type. Thus the function header: Function Pegadescricao(checklistbox: Tfrxchecklistboxcontrol) is: String;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.