starcraft Posted July 4, 2003 Posted July 4, 2003 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? Quote
JABE Posted July 4, 2003 Posted July 4, 2003 Try this: Dim ctrl As Control For Each ctrl In Me.Controls ctrl.Visible = Not (TypeOf ctrl Is Button) Next Quote
*Experts* mutant Posted July 4, 2003 *Experts* Posted July 4, 2003 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? Quote
JABE Posted July 4, 2003 Posted July 4, 2003 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. Quote
starcraft Posted July 4, 2003 Author Posted July 4, 2003 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 :( Quote
Leaders dynamic_sysop Posted July 4, 2003 Leaders Posted July 4, 2003 are you saying you want to actually be able to send info from another form to a different one? Quote
starcraft Posted July 4, 2003 Author Posted July 4, 2003 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 Quote
*Experts* mutant Posted July 4, 2003 *Experts* Posted July 4, 2003 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. Quote
Leaders dynamic_sysop Posted July 4, 2003 Leaders Posted July 4, 2003 i've attached a sample project with 3 forms and 2 buttons on the main form to hide the other forms , except the form2 or form3 depending on the button , and a button on form2 and form3 to then show all forms again. give it a try and let me know if it makes sense :)windowsapplication12.zip Quote
starcraft Posted July 4, 2003 Author Posted July 4, 2003 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 Quote
Leaders dynamic_sysop Posted July 4, 2003 Leaders Posted July 4, 2003 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 :) Quote
Leaders dynamic_sysop Posted July 4, 2003 Leaders Posted July 4, 2003 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 ) Quote
starcraft Posted July 4, 2003 Author Posted July 4, 2003 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? Quote
Leaders dynamic_sysop Posted July 4, 2003 Leaders Posted July 4, 2003 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 :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.