switch between design-time mode and run-time mode

Hi all,

I'm doing a windows form designer project.  Right now I have the design-time mode made, namely, I can use the project to create different form designs at design time.  My problem is that I need to be able to switch between design-time mode and run-time mode.  Say, when the project is in design-time mode, the user can changes properties of controls in design mode, and when it's in run-time mode, the user can enter data to the controls.  Any idea how to do it   When I switch to the run-time mode, do I have to recreate an instance for each of the controls, and set it's properties as well   Or there's an easy way to switch between the two modes  

Thanks.
Kim


Answer this question

switch between design-time mode and run-time mode

  • Jay-r

    sangminny,

    I think I could benefit by seeing your project - would you mind linking your project at its current location I do not see a link at your blog to Designer-sangminny.zip...


  • Carlos G uzman Alvarez

    It's good idea.

    Can I get sample code

    thanks


  • NeoRJ

    I uploaded the sample.

    this is not completed. but, I hope it's helpful.

    http://blog.naver.com/sangminny/110005716781


  • Finse

    I'm not sure it will work, but you could try the following:
    the moment the user wants to switch from run- to designmode, you could create the designer form, and then put the running form as childcontrol in it.

    Marc 

  • SAPO19875

    I did not have to filter out properties. What exception did you get


  • MeMe_89765

    I changed the method to copy properties.

    it looks like working...

    as you mentioned, filtering properties isn't problem.

    thanks Kimberly


  • ckzulueta

    Sorry I can't open your project because I have an older version of VB .net IDE.

    I suggest you do a first hand exception catch to understand the issue.


  • Liron231

     

    I'm not sure my approach is same to Kimberly's

    Assumption : user is operating a panel.

    •  run-time => design-time
      1. make a new DesignSurface(typeof(UserControl))
      2. copy all controls in the panel into DesingSurface
        • create component by using host.CreateComponent(original.GetType())
        • copy all properties by using cloneProperty.SetValue(clone, originalProperty.GetValue(original))
      3. clear all controls of panel
      4. add DesignSurface.View into panel.
      5. user can do adding, moving, deleting, changing properties
    • design-time => run-time
      1. remove DesignSurface.View from panel
      2. copy all controls in host.RootComponent into panel
        • create component by using Activator.CreateInstance(original.GetType())
        • copy all properties by using cloneProperty.SetValue(clone, originalProperty.GetValue(original))

    but, If I copy all properties, this process raises Exception. Which properties do I have to filter about I need help.

    thanks


  • Amit Thakur

    Thanks for your reply.  I'll try it.

    Kim

  • Bladergr

    Thanks Marc! Problem solved! Since I have the function to create the components in the design time, which uses host.CreateComponent. I just modified that function by using Activator.CreateInstance instead of host.CreateComponent. Then I got everything for the view mode. It took me about two days to discovery this easy solution. I'm so happy!Big Smile


  • tjtooj

    thank you for your reply

    it's difficult to explain what is problem. because of my english problem,

    I attached sample. 

    please watch 'StartDesign' function of ControlDesigner class in Designer Project. and run this sample.

    I'm finding the reason of the error, your short comment will be good help to me. please let me know what you can find in my sample code.

    thank you

    this link is my blog. please download attached file

    http://blog.naver.com/sangminny/110004722669 -> Designer-sangminny.zip

     


  • switch between design-time mode and run-time mode