Results 1 to 8 of 8

Thread: Copy Control(s) to another form

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2018
    Location
    Texas
    Posts
    168

    Question Copy Control(s) to another form

    I have a form having a frame which includes a number of Command Button controls. I want to copy this frame (and its controls to another form). I tried the copy and paste Ctl-C, Ctl- V way but no joy. I can do this Ctl-C, Ctl- V if I am on the same form, but it is across forms that I am wanting to do. (It does not have to copy with its underlying code - I can always add that afterwards.)

    I can make a user control, but I was wanting to see about this way, 1st to round out my understand if it is possible, and 2d how to do it.

    Ideas?
    Last edited by clickman; Oct 24th, 2021 at 09:14 AM.

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Copy Control(s) to another form

    Select the container control itself. Then copy/cut it, select the destination Form or container, paste. All done.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2018
    Location
    Texas
    Posts
    168

    Re: Copy Control(s) to another form

    Quote Originally Posted by dilettante View Post
    Select the container control itself. Then copy/cut it, select the destination Form or container, paste. All done.
    I see is was ambiguous. I have tried selecting the Frame containing the objects and copy and pasting it across forms, but that did not work. I think that frame selection is what you were indicating. I have also tried it with a single command button to no avail. Copy and past in the same form is ok but not across forms. Perhaps my IDE is a bit corrupted.

    I did find the frame and its objects in my text editor and I can copy and paste from the source form text file to the target form's text file and it shows up fine. but the direct copy paste seems like it dust does not want to do it.

  4. #4
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,064

    Re: Copy Control(s) to another form

    Copy and paste of controls between forms works perfectly.
    I don't know why it is not working for you.
    Try with a new project.

  5. #5
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Copy Control(s) to another form

    Just for curiosity I tried it here with a frame containing a label a couple text boxes and a couple buttons.
    I could not find a way to make it not work. If I select just the frame then the frame and eveything in it is copied and pasted.
    If I drag out a box over the entire frame again everything is pasted. If I select each control but not the frame then just the controls are pasted and if I select each contol and the frame then everything is pasted as expected.

    Are you sure your controls are actually in the frame rather than on top of it?

    If you are not sure try to move the frame on your form. If the controls move with in then they are in the frame if they do not move with it then they are not in the frame but on top of it and will not be copied with the frame.

  6. #6
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: Copy Control(s) to another form

    I've not only copied controls from one form to another, I've copied them from one instance of the VB6 IDE to another Instance of the VB6 IDE, i.e. between two different projects. It sure seems odd that it isn't working for you.
    "Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930

  7. #7
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,176

    Re: Copy Control(s) to another form

    I think DataMiser addressed your issue. But, to be sure, try this...add a NEW frame to your first form (don't put any controls in/on it). Select the frame, and copy-paste it to a second form...does THAT work (that is, the empty frame is copied to the second form?

    If so, then what DataMiser summises is correct; your commandbuttons were not added to the frame. To do that, select the frame, then add the command buttons to that frame. If you don't select the frame first, the commandbuttons are 'on' the frame, not 'in' it.

    Sammi
    Sam I am (as well as Confused at times).

  8. #8
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,443

    Re: Copy Control(s) to another form

    Errr.....Save the Form as another Form with a different name?
    In Windows-Explorer copy/paste to another Folder, rename, move it back, import it into the project? change the formname, since the IDE would recognize it as duplicate and give it a generic name
    You'd even get the underlying code for free.....
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width