Greetings to everyone!!! 
I am working on a couple of UserControls lately and this time is a custom TitleBar. What I want to do is to detect when ParentForm's properties (like ControlBox for example) is changing by developer in Design Time and then update my TitleBar.
So I added a Timer into my UserControl to do this "work". It works, but I think this isn't the most appropriate approach...
vb.net Code:
Private Sub Timer_Tick(sender As Object, e As EventArgs) Handles Timer.Tick Me.ControlBox = Me.ParentForm.ControlBox
If ParentForm.ControlBox = True Then ControlsBox_FlowLayoutPanel.Visible = True Else ControlsBox_FlowLayoutPanel.Visible = False
If ParentForm.MinimizeBox = True Then MinimizeButton_PictureBox.Visible = True Else MinimizeButton_PictureBox.Visible = False
Me.MinimizeBox = Me.ParentForm.MinimizeBox
If ParentForm.MaximizeBox = True Then MaximizeButton_PictureBox.Visible = True Else MaximizeButton_PictureBox.Visible = False
Me.MaximizeBox = Me.ParentForm.MaximizeBox
End Sub
Is there any other way to do that and not by using a Timer? For example, to detect ParentForm's Text property and then update my UserControl's Text, I do something like this...
vb.net Code:
Private WithEvents _ParentForm As Form
Protected Overrides Sub OnParentChanged(e As EventArgs)
MyBase.OnParentChanged(e)
_ParentForm = Me.ParentForm
Call ParentForm_TextChanged()
End Sub
Private Sub ParentForm_TextChanged() Handles _ParentForm.TextChanged
If _ParentForm Is Nothing Then
FormTitle_Label.Text = FormTitle_Label.Text
Else
FormTitle_Label.Text = _ParentForm.Text
End If
Invalidate()
End Sub
Is there anything similar for properties like ControlBox, MinimizeBox and MaximizeBox?
Thank you in advance!!!