|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DesignMode broken - suggested path?In doing some research, I've learned that some other people have had problems with Me.DesignMode not working correctly when it's used in a user control that is placed on another form. There was a suggestion... Protected Shadows ReadOnly Property DesignMode() As Boolean Get If (MyBase.DesignMode) Then Return True Else Dim parent As Control = Me.Parent While Not (parent) Is Nothing Dim site As ISite = parent.Site If Not (site) Is Nothing AndAlso site.DesignMode Then Return True End If parent = parent.Parent End While Return False End If End Get End Property ....but this suggestion does not work effectively. Does anyone know of another way and/or a supplement to this recursive function that I am not seeing? I've heard that you can use GetCurrentProcess, but that didn't seem to work for me. Thanks, Kyjan Kyjan,
I don't know if others understand this text but I don't. > A user control can be placed on every form, therefore I have the idea that > In doing some research, I've learned that some other people have had > problems with Me.DesignMode not working correctly when it's used in a > user control that is placed on another form. There was a suggestion... > you mean something else? Cor My apologies, I should have elaborated a little more.
I have created a user control that has some code that needs to run in the Load event. When I compile the user control and then place the user control on another form, because of the fact that the designer actually instantiates the class, it runs the code in the Load event. I'm trying to prevent that by testing the DesignMode property. However, it's not working correctly because even though the UC might not be in design mode, the form that the UC is on is in DesignMode. Kyjan Cor Ligthert [MVP] wrote: Show quoteHide quote > Kyjan, > > I don't know if others understand this text but I don't. > > > > In doing some research, I've learned that some other people have had > > problems with Me.DesignMode not working correctly when it's used in a > > user control that is placed on another form. There was a suggestion... > > > A user control can be placed on every form, therefore I have the idea that > you mean something else? > > Cor I would put your code into a public subroutine of the control and call it
from the load event of the form instead of the load event of the control - assuming that will accomplish what you want. As you've found, you can't rely on control events to happen when you think they should. In VS03 I've had a lot of problems with user controls firing events at odd times and repeatedly. It's a little more work, but it works for me. hth; DCraig. Show quoteHide quote "Kyjan" <HolySaphAn***@gmail.com> wrote in message news:1151674592.811298.203450@y41g2000cwy.googlegroups.com... > Does anyone have any suggestions? > > Kyjan > |
|||||||||||||||||||||||