Guest makai Posted November 28, 2002 Posted November 28, 2002 In VB6 no problem from Form1: Form2.Picture1.Picture = LoadPicture("c:\my.jpg") in .Net you can't even reference Form2.Picture1 why not? (I know it is declared as Friend - how do you fix it so you can reference it from another form?) Quote
wyrd Posted November 28, 2002 Posted November 28, 2002 Dim form As Form2 = New Form2() form.Picture1.Picture = LoadPicture("c:\my.jpg") Quote Gamer extraordinaire. Programmer wannabe.
sethindeed Posted February 5, 2003 Posted February 5, 2003 Wyrd : It does not work if the form is already loaded. It will operate the changes on a virtual form that can't be shown twice. I am stuck with the same problem and this is starting to give me headache Quote What I don't know keeps me excited...
wyrd Posted February 5, 2003 Posted February 5, 2003 See if what this guy suggests works.. http://www.xtremedotnettalk.com/t69406.html Quote Gamer extraordinaire. Programmer wannabe.
Leaders quwiltw Posted February 6, 2003 Leaders Posted February 6, 2003 My guess is that you're declaring it and creating your instance in the same method/event handler. If that's the case, just declare the variable for form2 outside the routine you create the instance with. Sounds like your pointer to form2 is out of scope when that routine completes. Something like this... Class form1 Inherits Form Private frm2 As Form2 Sub CreateForm2() frm2 = New Form2 End Sub Sub ChangeForm2() frm2.Picture1.Picture = LoadPicture("c:\my.jpg") End Sub End Class Quote --tim
sethindeed Posted February 6, 2003 Posted February 6, 2003 There is certainly something I don't understand... Dim frm as new Form1 frm.setheight(200) The code does not generates any error but they are no changes made on the hieght of the form. I declared my function Public and Friend on Form1 with no results...Does this have something to do with NEW Keywork ? I created Form2 from Form1 : Dim frm as new Form2 frm.ShowDialog() Is there any parameter I am missing ? Please note that Form1 is an MDI Parent form and that form2 is a modal form used to log to the program ( username, password ) thx ! Quote What I don't know keeps me excited...
Leaders quwiltw Posted February 6, 2003 Leaders Posted February 6, 2003 Ummm... are you double posting for fun or what? Obviously I'm reading both threads:) Quote --tim
sethindeed Posted February 6, 2003 Posted February 6, 2003 hehe ;) OK, I'll try to get the fundamentals of your saMPLE AND TRY TO WORK IT OUT mANY THANX Quote What I don't know keeps me excited...
sethindeed Posted February 6, 2003 Posted February 6, 2003 I tried it any possible way, nothing works ! :( Actually, I led. I am not trying to update the height of FOrm1 but trying to set the menu item enabled property ti true once the log when username and password. I looked in my debugger, they all convert to enabled = True but no changes occurs My thoughts are that I am operating the changes only on a virtual version of FOrm1 :( Quote What I don't know keeps me excited...
sethindeed Posted February 6, 2003 Posted February 6, 2003 I did some other tests and my feelings were right. The enabled property on Form1 is still false even if it gives me true when setting it to true in Form2 Quote What I don't know keeps me excited...
Leaders quwiltw Posted February 6, 2003 Leaders Posted February 6, 2003 What's your reference to the mdiparent? Are you setting that before you call for your changes? Quote --tim
sethindeed Posted February 6, 2003 Posted February 6, 2003 Yes, I am setting it before calling for the changes... DO I have to delcare MDIForm as Public Shared or something and if so, how can I do that ? thx Quote What I don't know keeps me excited...
Leaders quwiltw Posted February 6, 2003 Leaders Posted February 6, 2003 could you *please* just post the relevant code exactly as it is in your IDE. I'm confident it'll save us both a lot of time:) Quote --tim
sethindeed Posted February 6, 2003 Posted February 6, 2003 Here it is :) In my MDIForm Public Class MDIForm1 Inherits System.Windows.Forms.Form Private tmpLogin As frmConnexion (...) Private Sub mnuConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuConnect.Click tmpLogin = New frmConnexion() tmpLogin.ShowDialog() (...) In my frmConnexion : Public Class frmConnexion Inherits System.Windows.Forms.Form Private tmpMDIForm As MDIForm1 (...) BUtton1_click tmpMDIForm = New MDIForm1() tmpMDIForm.EnableMenus() Me.Close() (...) Quote What I don't know keeps me excited...
Leaders quwiltw Posted February 6, 2003 Leaders Posted February 6, 2003 Public Class MDIForm1 Inherits System.Windows.Forms.Form Private tmpLogin As frmConnexion (...) Private Sub mnuConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuConnect.Click tmpLogin = New frmConnexion() 'Add a reference to the parent since you're using ' ShowDialog, I don't think you can do it using the ' normal mdiparent/child relationship. tmpLogin.tmpMDIForm = Me tmpLogin.ShowDialog() (...) In my frmConnexion : Public Class frmConnexion Inherits System.Windows.Forms.Form Private tmpMDIForm As MDIForm1 (...) BUtton1_click 'commented new stuff. if it helps, your hunch was correct. ' your creating a whole new form that never gets shown. 'tmpMDIForm = New MDIForm1() tmpMDIForm.EnableMenus() Me.Close() (...) Quote --tim
sethindeed Posted February 6, 2003 Posted February 6, 2003 Yes yes yes :) The only change I made was to declare tmpMDIForm Public instead of private. Thanx for taking the time to go through all this. As a VB6 user, I am having some trouble to get acclimated to my new environment :) Your help was welcomed ;) Quote What I don't know keeps me excited...
Leaders quwiltw Posted February 6, 2003 Leaders Posted February 6, 2003 yeah I missed the private to public change. glad to hear you got it working. Quote --tim
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.