I use visual basic 2008
I use Groupbox1
In the Groupbox1 in have two labels: label1 and label2.
I have change the font of label1 with properties to size 12
No i change the font size of Groupbox1 with properties to size 8
Only label2 inherit font (8) format from GroupBox1 and label1 inherit not font change

I want that label1 and label2 inherit font from GroupBox1, always!

I how can i do this?

Member Avatar

If you just want to do it from the designer then don't set the font property. If you set the font property then to reset it: Select Label1's Font property and highlight all the font text description and then delete it. That will put it back to its default state and will then inherit the groupbox's font.

If you want to add a binding then you could add one in the load event of the form.

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Label1.DataBindings.Add(New Binding("Font", GroupBox1, "Font", False, DataSourceUpdateMode.OnPropertyChanged))
End Sub

That will change the label's font to the groupbox's font when you change the groupbox's font. No matter if you change the label's font or not.

That won't have any affect in the designer though. Only during runtime.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.