I can create and show a form that is loaded from a dll file via reflection. I want to trick the floating form into thinking it is in design mode. I think it should be possible to find a backing variable in the form somewhere and set it via reflection but I can't quite find it AND the code to set it. Can someone help me find a way to get the form to think it is in design mode?
I know the property is read-only but maybe there is an underlying field.
From thehennyy's comment, I made a phony class to act as a site:
public class MySite : IServiceProvider, ISite
{
public IComponent Component => null;
public IContainer Container => null;
public bool DesignMode => true;
public string Name { get => ""; set => value = ""; }
public object GetService(Type serviceType)
{
return null;
}
}
Then before the form is launched I set the Site property to an instance of this class:
form.Site = new MySite();
This does work to make the form believe it is in design mode when actually it is not. Site is fortunately a public property.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.