Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

i am using visablity true false cause i dont know how to link to another form in the same project :( so i'm trying this but its not working.

dim button as button
For Each button In me.controls
           button.Visible = False
       Next

any suggestions?

  • *Experts*
Posted
What you have should work all good, becuase it does :). What errors are you getting ? You said something about no being able to link to another form, do you want to modify buttons on another form?
Posted
Actually, starcraft's solution will work if the only controls in the Me reference are of the Button class; otherwise, InvalidCastException. But you're right, mutant; that may not be the problem at all.
Posted
sorry maybe i wasn't clear, because i dont know how to have the user click a button and it go to another form in the same project i was going to have it were it clears all objects fromt the current form and then and then set only the thing relating to that button visable. this is a hard way to do it but i dont know how to link different forms :(
Posted

hmm now i'm getting confused. I wont to have a main screen when there will be a number of buttons. i 'wonted' to be able to have when the user click a spacific button it would link to another form in the same project. Example: we have form1 with 2 buttons in the background we also have form2 and 3 when the user click button 1 it will hide all forms and show form2 when the uer clicks button 2 it will hide all forms and show form3. *

i hope that gives u an idea as to where i'm going. i hope

  • *Experts*
Posted
The best way would be to pass the form instances in constructors. And then access them from there. You would have to modify the Sub New to accept argumets.
Posted
yeah thats what i wont to do but for sum reason there is no visible code on any of the files. i open them an there is nothing there??? i cant see the forms or anything?? but it works
  • Leaders
Posted

ok well here's the code version :

in Form1 :

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

       Me.AddOwnedForm(frm2)
       Me.AddOwnedForm(frm3)

   End Sub



   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       frm2.Show()
       frm3.Hide()
       Me.Hide()
   End Sub

   Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
       frm3.Show()
       frm2.Hide()
       Me.Hide()
   End Sub

   Public Sub ShowAllForms()
       Me.Show()
       frm2.Show()
       frm3.Show()
   End Sub

in Form2 :

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       Dim frmBoss As Form1 = Me.Owner
       frmBoss.ShowAllForms()
   End Sub

in Form3 :

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       Dim frmBoss As Form1 = Me.Owner
       frmBoss.ShowAllForms()
   End Sub

hope it helps :)

  • Leaders
Posted
np glad to have helped :) , quite an easy way to share data between forms really that , saves a lot of headaches and you can do it to pass data from one form to another's controls also ( eg : textbox /listbox etc )

Posted
heh i've almost finished the project that u helped me with. but i have one more question. How do i compair 2 text boxes to see if the information entered is the same and if not to make a msg box say something like" your passwords do not match" and if the do match then continue?
  • Leaders
Posted

   Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
       Select Case TextBox1.Text
           Case TextBox2.Text '/// same text in textbox2 and textbox1
               MessageBox.Show("the passwords match! ")
           Case Else '/// different texts
               MessageBox.Show("oops you typed the wrong password! ")
       End Select
   End Sub

hope that helps :)

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...