Change properties of a child form through a parent form

  • Thread starter Thread starter Susan Sullivan
  • Start date Start date
S

Susan Sullivan

How can I change properties of a child form through a parent form? I
have a child form with a rich text box. I want to control font
properties of the rich text box through a menu on the parent form.
How do I get the two to talk to each other?
 
Hello,

You need to create Property's for the child form. For each item that you
wish to have access in the parent form e.g.:

Public Property FontName() As String
Get
Return RichTextBox1.SelectionFont.Name
End Get
Set(ByVal Value As String)
''' sets the selection to the specified font, you can just
change the entire rich text box with .Font instead
RichTextBox1.SelectionFont = New System.Drawing.Font(FontName,
8, FontStyle.Regular)
End Set
End Property

Then your parent form would call the child form like,

Dim MyChildForm As New ChildForm
MyChildForm.FontName = "Tahoma"

Hope this helps
Simon Jefferies
Tools Programmer, Headfirst Productions
mailto:[email protected]
-
 
Susan,

* (e-mail address removed)-spam.invalid (Susan Sullivan) scripsit:
How can I change properties of a child form through a parent form? I
have a child form with a rich text box. I want to control font
properties of the rich text box through a menu on the parent form.
How do I get the two to talk to each other?

Let 'Form1' be the type of the child form and 'RichTextBox1' the control
on the child form:

\\\
DirectCast(Me.MdiChildren(10), Form1).RichTextBox1.Text = "Foo"
///
 
Back
Top