473,414 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

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:

Expand|Select|Wrap|Line Numbers
  1.  Dim SaveChangesResponse As DialogResult
  2.         SaveChangesResponse = MessageBox.Show("Are you sure you want to save changes?  " & _
  3.                     "Changes done here are permanant.", _
  4.                     "Save Changes?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, _
  5.                    MessageBoxDefaultButton.Button2, _
  6.                    MessageBoxOptions.DefaultDesktopOnly, False)
  7.  
  8.         If SaveChangesResponse = Windows.Forms.DialogResult.Yes Then
  9. 'this is when the window starts minimizing
  10.  
the source of this code is in form2 which i pull up with form1(which both minimizes).

any help would be greatly appreciated.thanks ^_^
Nov 1 '08 #1
3 1898
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

Expand|Select|Wrap|Line Numbers
  1. MainForm.StatusLabel.Text = "Attempting to save changes for vendors"
  2.         Dim SaveChangesResponse As DialogResult
  3.         SaveChangesResponse = MessageBox.Show("Are you sure you want to save changes?  " & _
  4.                                               "Changes done here are permanant.", _
  5.                                               "Save Changes?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, _
  6.                                             MessageBoxDefaultButton.Button2, _
  7.                                             MessageBoxOptions.DefaultDesktopOnly, False)
  8.  
  9.         If SaveChangesResponse = Windows.Forms.DialogResult.Yes Then
  10.             'the code for saving all changes done in the vendors
  11.             Dim RowsAffected As Integer = 0
  12.             Try
  13.                 VendorBindingSource.EndEdit()
  14.                 RowsAffected = TbL_VENDORTableAdapter1.Update(VendorViewDataSet1.TBL_VENDOR)
  15.                 If RowsAffected > 0 Then
  16.                     MainForm.StatusLabel.Text = "You have updated  '" & RowsAffected.ToString() & "' Row(s)"
  17.  
  18.                     MessageBox.Show("No problems encountered", "Sucessfull")
  19.                 Else
  20.                     MainForm.StatusLabel.Text = "A problem was encountered during updating. Could not save into the database"
  21.  
  22.                 End If
  23.             Catch ex As Exception
  24.                 MessageBox.Show("Problem Updating vendor: " & ex.Message)
  25.             End Try
  26.         Else
  27.             'TODO: make sure window dosen't minimize after clicking no
  28.             MainForm.StatusLabel.Text = "Edit folder operation cancelled."
  29.         End If
  30.  
  31.     End Sub
Nov 1 '08 #2
jg007
283 100+
I think this is because you are using ' MessageBoxOptions.DefaultDesktopOnly ' ,

from the help - ' DefaultDesktopOnly will cause the application that raised the MessageBox to lose focus. '
Nov 1 '08 #3
hello jg007, thank you so much, this solved my problem completely. I was wondering what that option does ^_^
Nov 1 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Vadym Stetsyak | last post by:
Hi there! Is there any way how can I stop garbage collection for a period of time. Lets say, I have a form. Before form load I pause the GC and when the form is shown resume GC
3
by: NL | last post by:
Hi, Does anybody know how to turn off the animation Windows does with a window as it's minimized/maximized to the taskbar? I have an app which, when minimized, syncs to any other open...
13
by: Nathan | last post by:
Hello again, I have an application with three forms. Frm1 has a button whose click event calls frm2 -- frm2.ShowDialog(). Frm2 has a button that calls frm3 -- frm3.ShowDialog(). When I...
4
by: Tony Clark | last post by:
Hi, How can i tell when a form is minimizing or closing by use of the button in the top right of the form? thanks in advance
7
by: Lee | last post by:
Hi, How do I detect when a form is minimizing? specifically when a user clicks the show desktop button on the taskbar, rather than the minimize button on a form. thanks in advance
1
by: Zectron | last post by:
I have made my custom application from which i can access all other installed application using Shell function. I need to send this application to system tray upon minimizing. How to do it?? Please...
5
by: Scott | last post by:
Hi everyone, I have a c# console app that when run through an autorun.inf file, launches a web page from the CD. It works just fine but I would like the console window minimized on startup....
0
by: zyxwvu | last post by:
Dear All, I am developing project. on minimizing the from it should go to the system tray and not show on the task bar.. could u please help me in this way. Thanks and Regards Ravikrishnakumar
2
by: kimiraikkonen | last post by:
Hi, Maybe simple, but i couldn't find the correct class for minimizing current form when a "button" is clicked. Thanks.
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.