Stop Minimizing the form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • qazplm114477
    New Member
    • Oct 2008
    • 19

    Stop Minimizing the form

    Hi, I'm having a tiny problem. I have just started playing around with visual basic a week ago so im fairly new at this. I created a method that saves changes when you click a button, once the button is clicked a message box pops up with a yes/no option. whenever i click any of those buttons the entire window minimizes. Theres no problem with the code it self yet, i just want my window to stop minimizing

    here is the code:

    Code:
     Dim SaveChangesResponse As DialogResult
            SaveChangesResponse = MessageBox.Show("Are you sure you want to save changes?  " & _
                        "Changes done here are permanant.", _
                        "Save Changes?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, _
                       MessageBoxDefaultButton.Button2, _
                       MessageBoxOptions.DefaultDesktopOnly, False)
    
            If SaveChangesResponse = Windows.Forms.DialogResult.Yes Then
    'this is when the window starts minimizing
    the source of this code is in form2 which i pull up with form1(which both minimizes).

    any help would be greatly appreciated.tha nks ^_^
  • qazplm114477
    New Member
    • Oct 2008
    • 19

    #2
    I think the problem has something to do with the status label in form one, because every time a click event is triggered in form2, i would display what happened in the status lable in form 1 (StatusLable in a statusStrip ofcourse)

    here is the entire code

    Code:
    MainForm.StatusLabel.Text = "Attempting to save changes for vendors"
            Dim SaveChangesResponse As DialogResult
            SaveChangesResponse = MessageBox.Show("Are you sure you want to save changes?  " & _
                                                  "Changes done here are permanant.", _
                                                  "Save Changes?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, _
                                                MessageBoxDefaultButton.Button2, _
                                                MessageBoxOptions.DefaultDesktopOnly, False)
    
            If SaveChangesResponse = Windows.Forms.DialogResult.Yes Then
                'the code for saving all changes done in the vendors
                Dim RowsAffected As Integer = 0
                Try
                    VendorBindingSource.EndEdit()
                    RowsAffected = TbL_VENDORTableAdapter1.Update(VendorViewDataSet1.TBL_VENDOR)
                    If RowsAffected > 0 Then
                        MainForm.StatusLabel.Text = "You have updated  '" & RowsAffected.ToString() & "' Row(s)"
    
                        MessageBox.Show("No problems encountered", "Sucessfull")
                    Else
                        MainForm.StatusLabel.Text = "A problem was encountered during updating. Could not save into the database"
    
                    End If
                Catch ex As Exception
                    MessageBox.Show("Problem Updating vendor: " & ex.Message)
                End Try
            Else
                'TODO: make sure window dosen't minimize after clicking no
                MainForm.StatusLabel.Text = "Edit folder operation cancelled."
            End If
    
        End Sub

    Comment

    • jg007
      Contributor
      • Mar 2008
      • 283

      #3
      I think this is because you are using ' MessageBoxOptio ns.DefaultDeskt opOnly ' ,

      from the help - ' DefaultDesktopO nly will cause the application that raised the MessageBox to lose focus. '

      Comment

      • qazplm114477
        New Member
        • Oct 2008
        • 19

        #4
        hello jg007, thank you so much, this solved my problem completely. I was wondering what that option does ^_^

        Comment

        Working...