|
-
Dec 10th, 2000, 07:41 AM
#1
Thread Starter
Member
Hi.
How do I know if the UserControl I created runs is designtime or runtime? Currently it uses a variable defined in a different module, and it can't use it on designtime when the project is not running.
This is what I did:
Module1.bas -
Code:
Dim operator As EventDispatcher
where event-dispatcher is a class in my project.
operator is set to new EventDispatcher by Form1.
User control -
Code:
Dim WithEvents listener as EventDispatcher
Private SubUserControl_Initialize()
set listener = operator
End Sub
You see that in design-time operator is not set, and I don't want to set it manualy, because the operator must be the same object throughout the project and I can't re-initialize it whenever a control loads.
Thanks.
Yosef Meller.
-
Dec 10th, 2000, 11:12 AM
#2
Fanatic Member
The code to determine if your control is running in design mode or runtime mode is as follows:
The UserMode returns True if the control is in run mode and False if it is in design mode. So let say you we're running a clock control and you only want it to display real time while in run mode. You could use:
Code:
Private Sub UserControl_InitProperties()
Timer1.Enabled = Ambient.UserMode
End Sub
Then re-write this property like this so you can tell when the mode changes.
Code:
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
Timer1.Enabled = Ambient.UserMode
End Sub
That's about all there is to it.
www.RealisticGraphics.net
Running VS.Net Enterprise & VB 6
Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML
MSN Messenger: kmsheff
-
Dec 11th, 2000, 02:21 AM
#3
Thread Starter
Member
Damn. It doesn't work.
Thanks. But why does it say "client site not found" when I use the control?
Yosef Meller.
-
Dec 11th, 2000, 04:18 AM
#4
Thread Starter
Member
The solution
Ok, I solved the problem. So, for the public information -
Don't attempt to use Ambient property of the user control in the Initialize event - use it in InitProperties or any event that occurs *after* Initialize.
Yosef Meller.
-
Dec 11th, 2000, 02:47 PM
#5
Fanatic Member
Yep, that was your problem. The control doesn't Initialize before the form, you have to wait for the form to start and then access your control. Good Job.
www.RealisticGraphics.net
Running VS.Net Enterprise & VB 6
Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML
MSN Messenger: kmsheff
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|