TfrxListBoxControl

Hi everybody!

I'm building this report that contains a dual list type of wizard in order to get some parameters prior to showing the report.

I'm having a lot of troubles with this property "SELECTED" (at least that is the property when I use the TListBox class in delphi).

I'm trying to do the classical "what do I have" and the "what do I want" listbox type of wizard. and for that, I need to use that property "SELECTED" so that I am able to know from which do I have to take off of the Source listbox and send to the Destination Listbox.

Probably the main problem is that I'm a beginner in Delphi and programming stuffs but I'm pretty sure that property is not doing what it is suposed to do.

Does anybody know a workaround for that or maybe a way of using that property itself???

This is an example of what I'm trying to do:

function GetFirstSelection(List: TfrxListBoxControl): Integer;
begin
for Result := 0 to List.Items.Count - 1 do
if TCustomListBox.Selected[Result] then Exit;
Result := LB_ERR;
end;


I appreciate any helpful answer, however, as I said, I'm still a beginner to delphi and I wont understand if the answer is too generic. Somebody other time told me to use the AddMethod and AddClass thing but I don't even know what that is supposed to be.

Thanks again!!!

Comments

  • edited 2:23PM
    I little has not understood.
    You it is necessary chosen field from one ListBox to move in another?
    Or will simply take the indexes chosen element?
  • edited 2:23PM
    Hi Den

    I need to get the SELECTED (chosen) field to put into another listbox.

    In delphi it would be the SELECTED property for the TListBox Class, but that does not seem to work here with fast reports.

    Thanks
  • edited 2:23PM
    FR 3.19.
    Here is Script example (simply get up script in report).
    var
    listBox1,listBox2:TlistBox;
    form:Tform;
    button:Tbutton;
    procedure BTNCLK(Sender:TButton);
    var
    i:integer;
    begin
    for i:=0 to listbox1.items.Count -1 do
    begin
    if Listbox1.Selected[i] then
    ListBox2.items.add(Listbox1.items.Strings[i]);
    end;
    
    
    end;
    
    begin
    form:=TForm.create(nil);
    form.visible:=true;
    form.setBounds(0,0,250,228);
    button:= TButton.Create(form);
    button.parent:=form;
    button.visible:=true;
    button.setbounds(104,84,16,16);
    Button.caption:='+';
    Button.OnClick:=@BTNCLK;
    
    ListBox1:=TlistBox.Create(form);
    ListBox2:=TlistBox.Create(form);
    ListBox1.parent:= form;
    ListBox2.parent:= form;
    ListBox1.SetBounds(0,0,100,200);
    ListBox2.SetBounds(124,0,100,200);
    ListBox1.Multiselect:=True;
    ListBox1.Multiselect:=True;
    ListBox1.Items.Add('1');
    ListBox1.Items.Add('2');
    ListBox1.Items.Add('3');
    ListBox1.Items.Add('4');
    ListBox1.Items.Add('5');
    ListBox1.Items.Add('6');
    ListBox1.Items.Add('7');
    ListBox1.Items.Add('8');
    ListBox1.Items.Add('9');
    end.
    
  • edited 2:23PM
    Den

    Thanks for the example, but the problem is that I'm using the TfrxListBoxControl
    instead of TListBox Class because I'm working inside of the TfrxReport component and I cannot see a way of using that TListBox Class inside that component.

    If there is a way of using TListBox component inside of the TfrxReport component tell me because the SELECTED property DOES NOT WORK for TfrxListBoxControl.

    Thanks
  • edited 2:23PM
    In TfrxListBoxControl no even property multiselect.
    Create all in script, without participation component TfrxComponent (exactly for this is created FS ;) ).
  • edited 2:23PM
    Thanks Den!! That worked pretty well!!!

    But my boss is really nitty-greedy and wanted me to find out a way of doing this with that very component (TfrxListBoxControl).

    So I found out a way after hours of research:

    On the .Create of the dataModule that I'm using as a Reports' repository I put the folowing lines:

    var
    GlobalScriptObj: TfsScript;
    cvClass: TfsClassVariable;
    begin
    inherited;
    // adds new properties and methods to the script
    GlobalScriptObj := fsGlobalUnit;
    cvClass := GlobalScriptObj.FindClass('TfrxListBoxControl');
    cvClass.AddIndexProperty('Selected', 'Integer', 'Boolean', CallMethod, False);
    end;


    function TdtmRelatorios.CallMethod(Instance: TObject; ClassType: TClass;
    const MethodName: String; var Params: Variant): Variant;
    var
    _TfrxListBoxControl: TfrxListBoxControl;
    begin
    Result := 0;
    if ClassType = TfrxListBoxControl then
    begin
    _TfrxListBoxControl := TfrxListBoxControl(Instance);
    if MethodName = 'SELECTED.GET' then
    Result := _TfrxListBoxControl.ListBox.Selected[Params[0]]
    else if MethodName = 'SELECTED.SET' then
    _TfrxListBoxControl.ListBox.Selected[Params[0]] := Params[1];
    end
    end;



    Thanks again!!

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.