PDA

Click to See Complete Forum and Search --> : showing a form and unloading the current one


donut
Mar 18th, 2002, 05:34 AM
this is probably a very simple thing to do, but i can't figure this out. i have a form that loads another form when you click a button, using this code:

Dim frm As New Form2
frm.Show
'Me.Dispose(True)

but if i uncomment the commented code to unload the current form, it unloads the whole project. :confused:

RichardAtherton
Mar 18th, 2002, 09:32 AM
just remember I'm a newbie so please all guru VB .Netters don't descend on me, if my own solution is poor, I had the same problem and I really didn't want nor was it appropiate to use MDI.

so this is what I did:

Dim AddNewCustomer As New NewCustomer()
AddNewCustomer.Owner = Form.ActiveForm
AddNewCustomer.Show()
me.visible = false

then I have a cancel button on the AddNewCustomer form which does this:

Dim Myowner As Form
Myowner = Me.Owner
Myowner.Visible = True
Me.Close()

this seems to prodcue the desired effect, in that my Main Menu form from which the form is called disappears and is replaced by the Add New Customer form, then when I click the cancel button, it exectues the MyOwner=Me.Owner ....... etc, making the menu visible agian and closing the Add New Customer form

donut
Mar 18th, 2002, 09:52 AM
thanks for the reply :) i'll give it a go, but there must be a more simple way of doing it than that, considering that it VB6 all you had to do was:

Form2.Show
Unload Me

:o

RichardAtherton
Mar 18th, 2002, 01:03 PM
If you find one let me know.

I've been tearing my hair out over the last couple of days and finally found a solution but not a very elegant one of passing data back to the calling form and then getting it to act on it and you know all I wanted to do, was to have a dockable form based on the position of my current form, showing a list of customers, then for them to double click on the row and pass back the account number to the calling form and for it to call my Customer Details change form for amending Customer Details, I do accept that the data grid is far more flexible and powerful than the VB6 flexigrid but boy oh boy am I having a time getting to grips with it - even just getting the contents of a specifc column in the current row selected on the datagrid proved a nightmare.

I think my main trouble is I'm new to object oriented programming