Showing different memos on the databand depending on a field value?
Hello,
To simplify the description let's say I use the following data structure (I use a more complicated one, this is only to understand my problem):
The query describes the animals, but there are some specific fields only for certain animals.
For example the fields
- Name
- Kind (Birds or Mammals)
- Number of teeth (this applies only to mammals)
- Color (this applies to both)
- Wingspan (this applies only to birds)
Now I create Memos in Delphi on the fly as:
FrMemo := Frxd_CreateMemo(DataBandMaster); // this is my own function to create an FrMemo
With FrMemo Do
Begin
Text := 'Kind: [<frxDBDatasetAnimals."Kind">]';
TopText := TopText +5*fr01cm; //moving the cursor
Top := TopText ;
Left := MyLeftMargin*fr01cm ;
DataBandMaster.Height := DataBandMaster.Height+ (FrMemo as TfrxComponent).Height;
End;
If I use the method above, every field is visible, no matter if it is a bird or mammal, so the "Number of teeth" would be seen at Flamingo.
And I need the following:
Name: Flamingo
Color: Pink
Wingspan: 1.2
Name: Lion
Color: yellow
Number of teeth: 42
Name: Crow
Color: Black
Wingspan: 0.7
So depending on the value of Kind, Fr would show different memos.
My real data is much more complicated, I have about 20 common fields, 12 fields for one kind and 18 fields for the other kind, so If I would simply hide the memos which has fewer fields it would be a big gap vertically.
Can I do this somehow?
To simplify the description let's say I use the following data structure (I use a more complicated one, this is only to understand my problem):
The query describes the animals, but there are some specific fields only for certain animals.
For example the fields
- Name
- Kind (Birds or Mammals)
- Number of teeth (this applies only to mammals)
- Color (this applies to both)
- Wingspan (this applies only to birds)
Now I create Memos in Delphi on the fly as:
FrMemo := Frxd_CreateMemo(DataBandMaster); // this is my own function to create an FrMemo
With FrMemo Do
Begin
Text := 'Kind: [<frxDBDatasetAnimals."Kind">]';
TopText := TopText +5*fr01cm; //moving the cursor
Top := TopText ;
Left := MyLeftMargin*fr01cm ;
DataBandMaster.Height := DataBandMaster.Height+ (FrMemo as TfrxComponent).Height;
End;
If I use the method above, every field is visible, no matter if it is a bird or mammal, so the "Number of teeth" would be seen at Flamingo.
And I need the following:
Name: Flamingo
Color: Pink
Wingspan: 1.2
Name: Lion
Color: yellow
Number of teeth: 42
Name: Crow
Color: Black
Wingspan: 0.7
So depending on the value of Kind, Fr would show different memos.
My real data is much more complicated, I have about 20 common fields, 12 fields for one kind and 18 fields for the other kind, so If I would simply hide the memos which has fewer fields it would be a big gap vertically.
Can I do this somehow?
Comments
Hello,
My problem is that there is a picture at left side, and the texts on the right (have a look at the picture attached)
How can I add child bands vertically on the right, while the picture remains at the left? Should I use Vertical bands too?
Have a look at the picture below
I mean, if an animal has all the fields populated, and considering the probable size of the contents of each memoview, will it always fit in that band?
Yes, all fields are in the same dataset and all MemoViews are on the same databand. It will always fit in the band (I dynamically expand it).
And if you find it interesting then source code (fr3) is attached as well.
Thank you.
It is interesting, I can download the Fr, but if I want to download Pdf , I got the Error: Sorry, but you do not have permission to use this feature. If you are not logged in, you may do so using the form below if available.
Hello,
I could download your last attachments, thank you (of course I logged in previously as well, otherwise I wouldn't have been able to download Fr).
The output looks just as I wanted, I will check the Fr file.
Mick
PS.
Sorry for misunderstanding your former post.
Hello Mick
Thank you very much for your example. Today I have had time to "transform" it into my environment and I can tell you that the solution is simple and yet amazing!