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!!!
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
You it is necessary chosen field from one ListBox to move in another?
Or will simply take the indexes chosen element?
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
Here is Script example (simply get up script in report).
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
Create all in script, without participation component TfrxComponent (exactly for this is created FS ).
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!!