Creating Custom DBText Components
Is it possible to create and register a new ppDBText component descendant
with special features, such as automatic "Proper"ing of a DBText field?
If so, where do I start to create such components? Is there an example?
I find myself repeatedly having to use label components and reformatting
database text at run-time. My most common reformats are:
Removing extraneous characters: '_','-', etc.
Propering: Converting JOHNNIE becomes Johnnie
Lookups: Integer 3 becomes "White"
Forcing uppercase: oFF becomes OFF
Forcing lowercase: 10X12 becomes 10x12
Expanding Booleans: TRUE becomes "Yes"
Expanding single characters (like lookup): N becomes "No"
Reformatting phone numbers: 713-555-1212 becomes (713) 555-1212
If something like this already exists and is reasonably priced I'd buy it
today. If I write them myself I'll give them away to anyone that want them.
Thanks,
-Johnnie
with special features, such as automatic "Proper"ing of a DBText field?
If so, where do I start to create such components? Is there an example?
I find myself repeatedly having to use label components and reformatting
database text at run-time. My most common reformats are:
Removing extraneous characters: '_','-', etc.
Propering: Converting JOHNNIE becomes Johnnie
Lookups: Integer 3 becomes "White"
Forcing uppercase: oFF becomes OFF
Forcing lowercase: 10X12 becomes 10x12
Expanding Booleans: TRUE becomes "Yes"
Expanding single characters (like lookup): N becomes "No"
Reformatting phone numbers: 713-555-1212 becomes (713) 555-1212
If something like this already exists and is reasonably priced I'd buy it
today. If I write them myself I'll give them away to anyone that want them.
Thanks,
-Johnnie
This discussion has been closed.
Comments
start on doing my own much more simple component.
I just want to take the text that would be printed by ppDBText and modify it
right before printing. The component has to be registered so I can drop it
on a report at design time.
-Johnnie
component
(ppCtrls.pas) and simply override the GetTheText function to make it do
what you want to.
Example of registration for ReportBuilder components:
procedure Register;
begin
RegisterNoIcon([TTWGrid]);
end;
initialization
ppRegisterComponent(TTWGrid, 'TWComps', 100, 0, 'TWGrid',
HInstance);
finalization
ppUnRegisterComponent(TTWGrid);
end.
Hope this help.
--
Daniel Lemire
http://www.digital-metaphors.com/tips/CustomDBTextComponent.zip
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
Until I get the components done is there an easy way to modify the text
before printing in the existing DBText components during one of the events?
I was just going to select a group of DBText components and assign the same
event handler, but I don't know which event/parameters to use and my tests
haven't worked right.
-Johnnie
But I'm still curious about doing it in code using an event in case that
comes up for another case.
-Johnnie
working.
Thanks!
event of the TppLabel or TppDBText. Just modify the Text parameter that's
passed in the event.
Example:
procedure TForm1.ppDBText1GetText(Sender: TObject; var Text: String);
begin
Text := LowerCase(Text);
end;
Cheers
--
Daniel Lemire
Programmeur,
Conception Design Ware Inc.
Tél.: 819-868-8853
Fax : 819-868-8855