Results 1 to 6 of 6

Thread: how to disable multiple opening of forms

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2012
    Posts
    38

    how to disable multiple opening of forms

    how can i disable multiple opening of forms.i have a mdi parent form,on other form i am using child.showdialog and it works perfectly.The problem comes when i have a form that has a button that opens another form..how do i restrict a user not to open other forms until this form is closed because when i use show.dialog on the other form that opens a new one the former remains in the background while i want it to close

  2. #2
    Addicted Member
    Join Date
    Dec 2009
    Location
    Arizona
    Posts
    185

    Re: how to disable multiple opening of forms

    Not sure how many forms you are using, but if it is not to many, I would just use an If then statement

    If Form2.visible = False or Form3.visible = False then
    ' Show whatever form needs to be shown
    Else
    exit sub ' do nothing
    End If

    Exit Sub exits the process, so nothing happens

    Another way you might go is accessing the forms collection, but I would only do that if
    you have a large number of forms.
    .
    We must question the story logic of having an all-knowing all-powerful God, who creates faulty Humans, and then blames them for his own mistakes.
    GENE RODDENBERRY
    .
    http://www.tachufind.com
    .

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2012
    Posts
    38

    Re: how to disable multiple opening of forms

    thanks for the response. i have incorporated your idea and i have
    if me.visible = true then
    frmmainmenu.enabled=false
    elseif me.visible=false then
    frmmainmenu.enabled=true
    end if

    but the main menu is remaining disabled once i open the me form(being the form new customer) and if i close the form that has the button to open the me form it still remains disabled

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: how to disable multiple opening of forms

    Where is this code exactly? In any case if me.Visible = false never applies because if me.Visible = false then me.running code = false too!

    vb.net Code:
    1. ' On Form2 which is your "Me"
    2. Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    3.         Form3.Show ' this is the form you only want one of
    4.         Me.Close()
    5.     End Sub
    6.  
    7. ' On Form3
    8.     Private Sub Form3_FormClosed(sender As System.Object, e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
    9.         Form2.Show()
    10.     End Sub
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  5. #5

    Thread Starter
    Member
    Join Date
    Apr 2012
    Posts
    38

    Re: how to disable multiple opening of forms

    i put the code on the main form ie the mdi. the me is referring to the form i am opening ie frmnewcustomer

    if frmnewcustomer.visible= true then
    radmenu.enabled = false
    else if frmnewcustomer.visible=false then
    radmenu.enabled = true
    exit sub
    end if

  6. #6
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: how to disable multiple opening of forms

    I don't care which form it's on, what event is it using? Can you really not see the difference in detail between my code samples and yours? Did you even try the suggestion I made?
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

Tags for this Thread

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