copy, paste

if anyone has any ideea how to copy and paste a component (class).
I need copy and paste EASY !!!!!

Comments

  • : if anyone has any ideea how to copy and paste a component (class).
    : I need copy and paste EASY !!!!!
    :
    Select the component(s). Then press CTRL+C to copy, and CTRL+V to paste. If you want to cut a component, the key is CTRL+X. These are standard keys throughout windows, and 90% of all windows apps.

  • : Select the component(s). Then press CTRL+C to copy, and CTRL+V to paste. If you want to cut a component, the key is CTRL+X. These are standard keys throughout windows, and 90% of all windows apps.
    :
    Not that zibadian

    dinamically created component!!!
    :)))))))))


  • :
    : : Select the component(s). Then press CTRL+C to copy, and CTRL+V to paste. If you want to cut a component, the key is CTRL+X. These are standard keys throughout windows, and 90% of all windows apps.
    : :
    : Not that zibadian
    :
    : dinamically created component!!!
    : :)))))))))
    :
    :
    :
    I only answered your question as you asked it.
    This might work: Create the new component, and then Assign() the source component to it. That should copy all the necessary properties to the new component.
  • {
    HELP !
    F1!
    F1!
    }
    unit Unit1;

    interface

    uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls;

    type
    TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    private
    { Private declarations }
    public
    { Public declarations }
    end;

    var
    Form1: TForm1;
    btn: array of TButton;
    nr_btn: word;

    implementation

    {$R *.dfm}

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    {Here create a Button}
    if nr_btn < 10 then begin
    setlength(btn,nr_btn+1);
    btn[nr_btn] := TButton.Create(Application);
    btn[nr_btn].Left := nr_btn*5;
    btn[nr_btn].Top := nr_btn*5;
    btn[nr_btn].Caption := '&'+inttostr(nr_btn)+' Btn Created';
    btn[nr_btn].Parent := Form1;
    btn[nr_btn].Name := 'btn'+inttostr(nr_btn);
    inc(nr_btn);
    end
    else messagedlg('Max nr_btn!',mtInformation,[mbOk],0);
    end;

    procedure TForm1.Button2Click(Sender: TObject);
    begin
    {Here copy a button ????}
    if (nr_btn < 10)and(nr_btn<>0) then begin
    setlength(btn,nr_btn+1);
    btn[nr_btn] := TButton.Create(Application);
    btn[nr_btn].Assign(btn[0]); //Here raise an error
    {
    Error: Cannot assign a TButton to a TButton
    How to Copy
    }
    inc(nr_btn);
    end
    else messagedlg('Arghhh !',mtError,[mbOk],0);
    end;

    end.

  • : {
    : HELP !
    : F1!
    : F1!
    : }
    : unit Unit1;
    :
    : interface
    :
    : uses
    : Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    : Dialogs, StdCtrls;
    :
    : type
    : TForm1 = class(TForm)
    : Button1: TButton;
    : Button2: TButton;
    : procedure Button1Click(Sender: TObject);
    : procedure Button2Click(Sender: TObject);
    : private
    : { Private declarations }
    : public
    : { Public declarations }
    : end;
    :
    : var
    : Form1: TForm1;
    : btn: array of TButton;
    : nr_btn: word;
    :
    : implementation
    :
    : {$R *.dfm}
    :
    : procedure TForm1.Button1Click(Sender: TObject);
    : begin
    : {Here create a Button}
    : if nr_btn < 10 then begin
    : setlength(btn,nr_btn+1);
    : btn[nr_btn] := TButton.Create(Application);
    : btn[nr_btn].Left := nr_btn*5;
    : btn[nr_btn].Top := nr_btn*5;
    : btn[nr_btn].Caption := '&'+inttostr(nr_btn)+' Btn Created';
    : btn[nr_btn].Parent := Form1;
    : btn[nr_btn].Name := 'btn'+inttostr(nr_btn);
    : inc(nr_btn);
    : end
    : else messagedlg('Max nr_btn!',mtInformation,[mbOk],0);
    : end;
    :
    : procedure TForm1.Button2Click(Sender: TObject);
    : begin
    : {Here copy a button ????}
    : if (nr_btn < 10)and(nr_btn<>0) then begin
    : setlength(btn,nr_btn+1);
    : btn[nr_btn] := TButton.Create(Application);
    : btn[nr_btn].Assign(btn[0]); //Here raise an error
    : {
    : Error: Cannot assign a TButton to a TButton
    : How to Copy
    : }
    : inc(nr_btn);
    : end
    : else messagedlg('Arghhh !',mtError,[mbOk],0);
    : end;
    :
    : end.
    :
    :
    You'll have to copy each of the relevant property and event values by hand, which is in your case the Left, Top, Caption and Parent.
    Note: each of the component's owner isn't the Application, but the Form on which it is placed. This could be important, when naming the component, since each name must be unique in the owner's list.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories