Newbie Question (How to change the string in a text box in form2 when toolbar button is clicked on another form2) 
Author Message
 Newbie Question (How to change the string in a text box in form2 when toolbar button is clicked on another form2)
Ok, so what you need to do is to create a wrapper for your textbox on the
other form. The problem is that controls on forms are Protected by default.
This means that they can only be accessed from within the form or any
classes that inherit from that form. In order to get around this, you can
expose your textbox as a public read-only property. For example:

Public Class Form2
   ' This is the form that contains the textbox
   ' Designer-created code omitted here
   Public ReadOnly Property myTextBox() As TextBox
      Get
         ' This line returns a reference to TextBox1
         Return TextBox1
      End Get
   End Property
End Class

Then in Form1, you can change the properties of this textbox by calling the
property, as follows:

Form2.myTextBox.Text = "Look at all this great text!!!"

 Hope this helps!!!

Matthew Stoecker and Cat Francis
Visual Basic User Education
Microsoft Corporation

--
This posting is provided "AS IS" with no warranties, and confers no rights.

--
This posting is provided "AS IS" with no warranties, and confers no rights.


Quote:
> Newbie Question

> I have form1 with a toolbar with ToolBarButton1 and ToolbarButton2
> and want to change tbAddress on form2 with a differnt string.

> string1 = www.test.com
> string2 = ftp.test.com

> How can I do it.
> Is AddHandler the right approch?

> Can somebody push me in the right direction or even provide me with a
> sample.

> TIA




Sat, 29 Jan 2005 03:40:19 GMT  
 Newbie Question (How to change the string in a text box in form2 when toolbar button is clicked on another form2)
Karl,
In order to easily change properties on Form2, you must have a reference to
an instance of Form2 in Form1.  Here's how we did it to change a label on
form2 by clicking a button in form1:

Form1.vb
    Private mForm2 As New Form2()
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
        mForm2.Show()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
        mForm2.Label1.Text = "it works"
    End Sub

Steve
VB.Net
--
This posting is provided "AS IS" with no warranties, and confers no rights.


Quote:
> Newbie Question

> I have form1 with a toolbar with ToolBarButton1 and ToolbarButton2
> and want to change tbAddress on form2 with a differnt string.

> string1 = www.test.com
> string2 = ftp.test.com

> How can I do it.
> Is AddHandler the right approch?

> Can somebody push me in the right direction or even provide me with a
> sample.

> TIA



Sat, 29 Jan 2005 04:05:06 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Newbie Question - Moving from text box to text box (without tab)

2. Newbie question: Rich Text Box vs. Text Box

3. Newbie Question:Text Box

4. Newbie Question: Force format in a text box

5. Newbie text box question

6. Default Button vs. Text Box - Newbie Question

7. newbie, text-box control questions

8. Simple Text Box Questions from Newbie

9. Newbie Question- Formatting a text box

10. Newbie with Text Box question....

11. dear text box guru(s): fancy text box question...

12. Modifying Text Format in use without changing text in entire text box

 

 
Powered by phpBB® Forum Software