Click to See Complete Forum and Search --> : Property changing


tjm1976
08-08-2005, 07:00 AM
I am new to the .NET environment. I am an experienced VB6 programmer. What I would like to know is how to change the enabled property of a form using another form's code. I have a project written in VB6 that I am trying to convert and am having trouble with this. I know how to dim a variable and call it new form but I suppose this is a new intance of the form and will not make changes to the loaded form. Is this true? This project has 2 forms and one is a simple password form which will flag a user when data is out of spec. When this form (frmPassword) pops up I want to disable the main form until the correct the username and password are entered.

etoostr
08-08-2005, 07:22 AM
You can start your main form with visible=false, and toggle this property when the password form return.

tjm1976
08-08-2005, 07:34 AM
It is only when data is entered do I want this screen to show. What is the code to toggle this property?

etoostr
08-08-2005, 07:52 AM
I'm just answering this on top of my head, but: in the mainform I would call
me.visible=false
dim res as dialogresult = frmPassword.showdialog()
<check res and input (frmPassword.username & frmPassword.password)>
me.visible=true

tjm1976
08-08-2005, 10:15 AM
I have never used this approach before. I tried using the showdialog after my form name but it doesn't recognize it in the form editor. How do I get the data returned from this form?

etoostr
08-08-2005, 03:08 PM
Make the data available through properties that you declare as public readonly:

Public ReadOnly Property username()
Get
return mUsername
End Get
End Property

then you can get them from your instance in the mainform: frmPassword.username

You must of course also remember to create this instance in the mainform...
frmPassword = new FrmPassword() 'Sorry for the namemixup