Referencing control on one form from another form

后端 未结 8 2041
轻奢々
轻奢々 2020-12-12 01:30

As you can guess, I\'m kind of new to .NET and just want to reference a control on one form from another.

Usually I would just do Form.Control.Property but that does

8条回答
  •  长情又很酷
    2020-12-12 01:55

    While you can create a property on your second form that will return the data needed, you can just as easily change the Modifier property of that control. By default, the modifiers of controls are private, and therefore not accessible to anything other than the current form. Click on the control, and find the Modifier property. Set that to Public, and you'll be able to access it from outside the form, such as:

    Dim f As New SecondForm
    f.FirstNameTextBox.Text = "Bob"
    

提交回复
热议问题