|
-
Jul 5th, 2003, 06:11 PM
#1
Thread Starter
New Member
enabeling controls question
how can i reference controls on one form to enable them from anotehr form?
assuming I'm missing a dim statement someplace or something in the syntax but so far every thing that i've tried i've gotten some form of an error when trying to.
-
Jul 5th, 2003, 07:28 PM
#2
Re: enabeling controls question
Originally posted by ronman1123
how can i reference controls on one form to enable them from anotehr form?
assuming I'm missing a dim statement someplace or something in the syntax but so far every thing that i've tried i've gotten some form of an error when trying to.
UMM you have to have access to the form... you can declare a public variable in a module and set it equal to your form, ie
public mainForm as form
and in your main form set mainForm=me
then you can access it from the second form....
you could also change the New constructor of your second form to accept a variable of type form, and pass the main form to the new constructor
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Jul 5th, 2003, 07:44 PM
#3
Thread Starter
New Member
im sure it's probably the wrong way of doing but i've declared each new form in the form that i'm calling it from.
though your last comment confused me though
"you could also change the New constructor of your second form to accept a variable of type form, and pass the main form to the new constructor"
sorry for waht i know is such a simple question. was mostly self taught at vb 6 and am now struggeling through my first .net project. but the help is much appreciated
-
Jul 5th, 2003, 08:34 PM
#4
Originally posted by ronman1123
im sure it's probably the wrong way of doing but i've declared each new form in the form that i'm calling it from.
though your last comment confused me though
"you could also change the New constructor of your second form to accept a variable of type form, and pass the main form to the new constructor"
sorry for waht i know is such a simple question. was mostly self taught at vb 6 and am now struggeling through my first .net project. but the help is much appreciated
sorry I'm reinstalling vs.net now so I cant write an example, sorry if I confused you
say this is your second form. if you open up the region where it says "Windows Form Designer generated code " you'll see the New constructor. You can change it to something like this:
VB Code:
' in the second form:
Private callerForm as form
#Region " Windows Form Designer generated code "
Public Sub New(byval callerForm as form)
me.callerForm = callerForm
'.....
End Sub
....
.....
......
#End Region
private sub foo()
' you can access the other form like this
callerForm.text = "boo"
end sub
hope this explains it sorry I'm kinda bad in explaining something, hehe
edit: when you're creating a new form you have to pass the caller form to new(). IE, if your second form is called frmSecond and you are creating an instance of it, you should do something like this
VB Code:
dim frm as new frmSecond (me) ' pass "me" to the constructor
frm.show()
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Jul 5th, 2003, 08:44 PM
#5
Thread Starter
New Member
okay i see what you were getting at
thanks much for the quick replies and the help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|