Eddie Shipman
asked on
Property editor needed {worth 200 pts!}
I have a component that takes a TDataset
and formats its result to XML. I need a
property and property editor that will
allow the selection of which fields in
the dataset to use as Attributes. The
other fields not selected will be
presented as Elements in the resulting
XML document.
I'm thinking of having a dialog with a
TCheckListBox on it where the
AttributeFields can be checked.
This is the next-to-last thing I need
for this component and I don't know
where to begin on this one...
If you have specific questions, contact
me via e-mail at eshipman@e-mds.com...
and formats its result to XML. I need a
property and property editor that will
allow the selection of which fields in
the dataset to use as Attributes. The
other fields not selected will be
presented as Elements in the resulting
XML document.
I'm thinking of having a dialog with a
TCheckListBox on it where the
AttributeFields can be checked.
This is the next-to-last thing I need
for this component and I don't know
where to begin on this one...
If you have specific questions, contact
me via e-mail at eshipman@e-mds.com...
ASKER
I need something more along the lines of the TFieldsEditor where I can build
a fieldlist of fields I want to write
as Attributes.
This is for strings only...
a fieldlist of fields I want to write
as Attributes.
This is for strings only...
ASKER
Well, Since I actually came up with my
own solution, I'll give you 100 points
for answering with a source solution.
own solution, I'll give you 100 points
for answering with a source solution.
ASKER
I can't lower thepoints offered so I am deleting the question. If you'll
resubmit your answer, I'll accept it
for 100 points since you offered a
source soultion. I did, however, use
my own solution.
resubmit your answer, I'll accept it
for 100 points since you offered a
source soultion. I did, however, use
my own solution.
ASKER
This question has a deletion request Pending
ASKER
See above comment...
This question no longer is pending deletion
Eddie, You said you didn't know where to start on this one. I gave you a complete working example of a component editor 7 hours after you asked the question, and one day later you worked it out yourself.
If you didn't use my answer at all, then delete the question with no points given, otherwise accept this answer.
If you didn't use my answer at all, then delete the question with no points given, otherwise accept this answer.
ASKER
Cosidering, you posted a component editor .vs a property editor and I
needed a TStrings editor .vs an editor
for a Record, what do you think. I wrote
a TStrings PROPERTY editor and didn't
use any of your code at all. I'm
sending you a copy of the code to your
e-mail address to confirm it...
If you still want the 200 after seeing
my code, I'll approve it.
E
needed a TStrings editor .vs an editor
for a Record, what do you think. I wrote
a TStrings PROPERTY editor and didn't
use any of your code at all. I'm
sending you a copy of the code to your
e-mail address to confirm it...
If you still want the 200 after seeing
my code, I'll approve it.
E
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Well even your editor wasn't what I was looking for. If it had been a fields editor, sure, I would have probably used it. I couldn't see any way to conform it to what I was needing...
Sorry but I guess I didn't make myself clear enough...
Sorry but I guess I didn't make myself clear enough...
ASKER
Just to get rid of it all...
Double-clicking TMyComponent invokes a component editor where you can edit the fields of Stuff.
Right-clicking has a context menu where some simple actions can occur.
Because TStuff is a non-standard property type, I've added TFiler code to stream the fields of TSTuff to/from the *.DFM
I'll post the code here in case other E-E people want to read it, and I'll e-mail the sample app to you.
--------------------------
TMyComponent
--------------------------
unit Mycomponent;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, DsgnIntf,
StuffEditor;
type
TStuff = record
Number : integer;
Text : string[255];
end;
TMycomponent = class(tcomponent)
private
fStuff :TStuff;
procedure SetStuff(const Value: TStuff);
procedure DefineProperties(Filer:TFi
procedure WriteStuffText(Writer:TWri
procedure ReadStuffText(Reader:TRead
procedure WriteStuffNumber(Writer:TW
procedure ReadStuffNumber(Reader:TRe
protected
{ Protected declarations }
public
{ Public declarations }
published
property Stuff : TStuff read FStuff write SetStuff;
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Planet
RegisterComponentEditor(TM
end;
{ TMycomponent }
procedure TMycomponent.DefinePropert
begin
inherited;
Filer.DefineProperty('Text
Filer.DefineProperty('Numb
end;
procedure TMycomponent.ReadStuffNumb
begin
fStuff.Number := Reader.ReadInteger;
end;
procedure TMycomponent.ReadStuffText
begin
fStuff.Text := Reader.ReadString;
end;
procedure TMycomponent.SetStuff(cons
begin
FStuff := Value;
end;
procedure TMycomponent.WriteStuffNum
begin
Writer.WriteInteger(fStuff
end;
procedure TMycomponent.WriteStuffTex
begin
Writer.WriteString(fStuff.
end;
end.
--------------------
TStuffEditor
--------------------
unit StuffEditor;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Spin, dsgnIntf;
type
TStuffEditor = class(TComponentEditor)
function GetVerbCount:integer;overr
function GetVerb(index:integer):str
procedure ExecuteVerb(index:integer)
end;
TStuffDLG = class(TForm)
Edit1: TEdit;
SpinEdit1: TSpinEdit;
Label1: TLabel;
Label2: TLabel;
Button1: TButton;
private
{ Private declarations }
public
function Execute(Component : TComponent) : boolean;
end;
var
StuffDLG: TStuffDLG;
implementation
uses MyComponent;
{$R *.DFM}
{ TStufEditor }
procedure TStuffEditor.ExecuteVerb(i
var
tmpStuff : TStuff;
begin
inherited;
case index of
0 :
begin
try
StuffDlg := TStuffDlg.create(nil);
if StuffDlg.execute(Component
finally
StuffDlg.free;
end;
end;
1 :
begin
tmpStuff := TMyComponent(Component).St
tmpStuff.Text := 'hello world';
TMyComponent(Component).St
Designer.Modified;
end;
2 :
begin
tmpStuff := TMyComponent(Component).St
tmpStuff.Text := 'foo';
TMyComponent(Component).St
Designer.Modified;
end;
end;
end;
function TStuffEditor.GetVerb(index
begin
case index of
0:result := 'Open Dialog';
1:result := 'StuffText := hello world';
2:result := 'StuffText := foo';
end;
end;
function TStuffEditor.GetVerbCount:
begin
result := 3;
end;
{ TStuffDLG }
function TStuffDLG.Execute(Componen
var
tmpStuff : TStuff;
begin
tmpStuff := TMyComponent(Component).St
edit1.text := tmpStuff.Text;
spinedit1.value := tmpStuff.Number;
ShowModal;
result := ModalResult = mrOK;
if result then
begin
tmpStuff.text := edit1.text;
tmpStuff.number := spinedit1.value;
TMyComponent(Component).St
end;
end;
end.
----------------
StuffEditor DFM
----------------
object StuffDLG: TStuffDLG
Left = 335
Top = 212
Width = 321
Height = 198
Caption = 'Stuff Editor'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 24
Top = 24
Width = 37
Height = 13
Caption = 'Number'
end
object Label2: TLabel
Left = 24
Top = 88
Width = 21
Height = 13
Caption = 'Text'
end
object Edit1: TEdit
Left = 120
Top = 80
Width = 121
Height = 21
TabOrder = 0
Text = 'Edit1'
end
object SpinEdit1: TSpinEdit
Left = 120
Top = 24
Width = 121
Height = 22
MaxValue = 0
MinValue = 0
TabOrder = 1
Value = 0
end
object Button1: TButton
Left = 232
Top = 136
Width = 75
Height = 25
Caption = 'OK'
ModalResult = 1
TabOrder = 2
end
end