Results 1 to 4 of 4

Thread: showing a form and unloading the current one

  1. #1

    Thread Starter
    Addicted Member donut's Avatar
    Join Date
    Mar 2001
    Location
    London, UK
    Posts
    165

    showing a form and unloading the current one

    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:

    VB Code:
    1. Dim frm As New Form2
    2. frm.Show
    3. 'Me.Dispose(True)

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

  2. #2
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304
    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

  3. #3

    Thread Starter
    Addicted Member donut's Avatar
    Join Date
    Mar 2001
    Location
    London, UK
    Posts
    165
    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:

    VB Code:
    1. Form2.Show
    2. Unload Me


  4. #4
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width