CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2011
    Location
    .Net 4.0
    Posts
    39

    runtime DesignSurface controls quirk

    I am using the DesignSurface (ds) at runtime to allow end user to move and re-size controls.
    I want the user to be able to pre-view the form in another tab, the "Preview" tab. When user selects the preview tab, if you simply change the parent or copy all the controls from the "Design" tab into the "Preview" tab, the Preview tab acts just like the DesignSurface. It's as if there are some hidden control properties for each of the controls that port right over into the Preview tab.

    Is there a quick way to just dump all the ds controls into the preview tab without turning the preview tab into a designsurface?

    FYI, if you do the reverse (move controls from preview tab to design tab), it kills the designsurface functionality in the design tab. There must definitely be some hidden properties directing the designsurface behavior for each control.

  2. #2
    Join Date
    Dec 2011
    Location
    .Net 4.0
    Posts
    39

    Re: runtime DesignSurface controls quirk

    No takers?

    Apparently, it's probably not a "quirk." After exhaustive researching, I finally found that it appears that whether or not a control is in designer mode can be tested through the control.site.designmode property.

    This is, unfortunately, a read only property. ****, I wish it was settable! ;-(

    I tried the following, in which I would attempt to exclude the control.site.designmode property from being copied into my new control:

    Code:
    if (oldControlTypeString.Contains("CHECKEDLISTBOX"))
    {
               CheckedListBox newControl = new CheckedListBox();
               var oldControlProperties = oldControlType.GetProperties();
                 
               foreach (PropertyInfo property in oldControlProperties)
               {
    
                      var oldControlPropertyValue = property.GetValue(oldControl, null);
                       if (property.CanWrite && !property.Name.ToUpper().Contains("PARENT"))
                       {
                                   
                             if (oldControlPropertyValue != property.GetValue(newControl, null))
                             {
    
                                    property.SetValue(newControl, oldControlPropertyValue, null);
                              }
                         }
                   }
    
                    tct.TabPages[1].Controls.Add(newControl);
             }
    }
    Next step would be to exclude the site.designmode property, except that this code does not even make the control displayable when it is added. The newcontrol is definitely added, but something is wrong, and it will not display.

    Anybody have any idea on how to copy all settable properties into newcontrol from oldcontrol, except for the parent and desigmode?

    Or if not, can anyone spot why my newcontrol is failing to display?

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

Featured