Custom Controls: How to tell if it is being placed on the form for the first time?
Which even should I use to see if my control if being placed on a form for the first time? I want to do some error checked and I want to size it properly. UserControl_Initialize is called a few other times as well. Is there a better event to use?
Re: Custom Controls: How to tell if it is being placed on the form for the first time?
Now sure if this is of any help. will show a messagebox as soon as you add the control to the form.
Private Sub UserControl_Show()
On Error Resume Next
If Not (UserControl.Ambient.UserMode) Then
MsgBox "design time"
End If
End Sub
Re: Custom Controls: How to tell if it is being placed on the form for the first time?
The InitProperties event only occurs when the usercontrol is first sited on a form. It does not fire at runtime.
The Initialize event is always the first event to occur when an instance of the control is created, design time and runtime.
Re: Custom Controls: How to tell if it is being placed on the form for the first time?
But will InitProperties be called every time the project is loaded? I would think so. I guess I should go test it though ;).
Thanks guys. I'll see what I can come up with.