We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Need to access a textbox.text or a method in another form

It was easy in VB6 but how must I do in VB.NET. Searching in the internet I found two related articles: - How to Access Controls on Other Forms from vb.dotnet.technical in DEVX - Passing text between forms with VB.NET by Tim Ferguson in DEVHOOD But it cannot be used with your tools (not compatible with docking and MDItabbed).

9 Replies

AD Administrator Syncfusion Team September 16, 2002 01:25 PM

Any technique you might use to access controls in other forms should also be usable in our tabbed mdi. Could you give a little more info on your scenario? We could then suggest better. Regards, Praveen Ramesh


DR Dadang Rachmad September 17, 2002 07:36 AM

I include a sample in ZIP format, I hope it can be opened. I try to make the sample as simple as I could. Open status windows from the menu personal>status. Try input a data in the Maintree windows and click the refresh toolbar in the identity windows and status windows. I want that the refresh is done automatically without clicking the refresh toolbar. I hope you can understand the sample.


AD Administrator Syncfusion Team September 18, 2002 06:39 AM

Hi, This is how you could refresh the "Status" form: 1) Listen to the Validated event of the TextBox in the MainTree control. Assuming this is when you want to Refresh. You could do this in your MainForm form. 2) In the event handler, browse through the loaded Child-Forms by parsing the tabbedMDIManager.MdiChildren list. When you find the form of type "Status", get a reference to that Form, casting it to type Status and call a method, say Referesh, for example. Regards, Praveen Ramesh


DR Dadang Rachmad September 19, 2002 08:19 AM

Thanks for your reply. But I have some difficulty with point 1 of your answer that may be you can help. Actually I just beginning rewriting from VB6 to VB.NET. The most problematic is this logic which is easy in VB6 This is how you could refresh the "Status" form: 1) Listen to the Validated event of the TextBox in the MainTree control. Assuming this is when you want to Refresh. You could do this in your MainForm form. how?? I try to check the event/handles and found nothing. the MainTree is in DockingManager. 2) In the event handler, browse through the loaded Child-Forms by parsing the tabbedMDIManager.MdiChildren list. Private Function tabForm_get(ByVal formName As String) As Form Dim form As Form Dim formRet As Form For Each form In Me.tabbedMDIManager.MdiChildren If form.Name = formName Then formRet = form Exit For End If Next Return formRet End Function When you find the form of type "Status", get a reference to that Form, casting it to type Status Dim form As Form Dim obj As Object form = tabForm_get("Status") obj = CType(form, Status) and call a method, say Referesh, for example. obj.refresh ' Refresh must be Public I have test the point 2 and it seem OK, only the point 1?


AD Administrator Syncfusion Team September 19, 2002 12:24 PM

Hi, 1) When you select the textBox control in the top-left combo-box of your Form source you will see it's events in the top-right combo. You should then pick the Validated event in that list. It is in this list that you can Refresh the other Form as mentioned in 2). Regards, Praveen Ramesh


DR Dadang Rachmad September 20, 2002 02:43 AM

Thanks for your patience I know the event I want to listen but how I write in the MainForm because the Maintree control is under DockingControl and not directly under the MainForm. 1) Listen to the Validated event of the TextBox in the MainTree control. Assuming this is when you want to Refresh. You could do this in your MainForm form. In the MainForm: private sub something() handles Human_Resources.MainTree.Mytext1.validate ... end sub Sure the above does not work!!! But how? What should I wrote in the handles?


AD Administrator Syncfusion Team September 24, 2002 12:05 PM

Hi, It doesn't matter where the MainTree control is (in your controls hierarchy). You can listen to it's events as long as you have a reference to it. If you don't have a reference to it, then you should expose it from whatever wrapper class/control you have it in. Let me know if I am missing something. Regards, Praveen Ramesh


DR Dadang Rachmad September 29, 2002 05:30 AM

Sorry, I came from VB6 and not C++. Attached is a small sample, it does not work although there is no error. Do you mean like the sample or there is another method. Thanks.


AD Administrator Syncfusion Team September 30, 2002 07:15 AM

Hi, I added a line of code in this handler you had: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim NewForm As New MainTree() ' Update your reference every time. Me.MT = NewForm NewForm.Show() End Sub The xx handler now gets hit. Regards, Praveen Ramesh

Loader.
Live Chat Icon For mobile
Up arrow icon