Jump to content
Xtreme .Net Talk

Emptying both forms textboxes with a single click in client-server environment


Recommended Posts

Posted
If I got a MDIparent with 2 MDIchild in it, with each form(MDIchild) has a 2 textbox (1 is send textbox and another is received textbox) and 2 buttons (1 is Send button and the other is Reset button), does anyone know the way that when I click on Reset button, the received textbox on both forms will be emptied. I'm going to implement in client-server environment. Now, I only manage to clear one form Received textbox but not the other. Any ideas anyone? :confused:
Posted

if i understood correctly your trying to clear the textbox on another form in the same project to do that u have the code

Public frm2 As New Form2()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.AddOwnedForm(frm2)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
me.textbox1.text=""
me.textbox2.text=""
frm2.textbox1.text=""
frm2.textbox2.text=""
end sub

hope this helps ALSO i dont know if the code is EXACTLY correct just shout if its not and i'll fix it

:p

Posted

Yes, starcraft.

U understand correctly. I think to put it in a better way of words, I wanna access the properties inside MDIchild1 from MDIchild2.

I tried out the codes u gave..

It seems when u type ".", VB.NET doesn't seems to show the property of the form which in this case is a textbox I'm looking for. So I'm still stuck at the clearing textbox part since after declaring the form from what u have suggested, typing in the word "frm2" no longer gives me error but still to no avail, doesn't apply to the property inside the form.

Posted
hmmm..... i'm no expert by all means :p but i thought i'd throw in my thoughts cause i was dealing with muilti forms at one point and that is what i ended up using but i also didn't use MDIchild. So we might need to get an expert in here like Mutant of Volt.
  • *Experts*
Posted

What you could do is to either create a class wth shared members that you will assign an instance of your mdi children or create public variables in your parent and assign the child instances to those variables and then access them from children using the MDIParent property.

If you want to use the class with shared members then make a new class and make it look like this:

Public Class SharedInstances 'you can call this whatever you want
Private Shared _childoneinstance As ChildOneForm 'private variable of the child  type
Private Shared _childtwoinstance As ChildTwoForm
'then have properties to modify those variables
Public Shared Property ChildOne As ChildOneForm 'property of the form's type
Get
      Return _childoneinstance
End Get
Set (Byval Value As ChildOneForm)
      _childoneinstance = Value
End Set
End Property
'and then for the second one
Public Shared Property ChildTwo As ChildTwoForm 'property of the form's type
Get
      Return _childtwoinstance
End Get
Set (Byval Value As ChildTwoForm)
      _childtwoinstance = Value
End Set
End Property

Then when you create those two children from your parent set those properties to the instances your created in your parent.

SharedInstances.ChildOne = variablewithinstance
SharedInstances.ChildTwo = variablewithinstance

Then you can access the shared class like this from any other form in that project:

SharedInstances.ChildOne.SomePropertyormethod()

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...