Questions tagged [dialogresult]

DialogResult is returned by dialogs after dismissal. It indicates which button was clicked on the dialog by the user. It is used with the MessageBox.Show method. It is a value. It can be switched upon and tested in an if-statement.

DialogResult is returned by dialogs after dismissal. It indicates which button was clicked on the dialog by the user. It is used with the MessageBox.Show method. It is a value. It can be switched upon and tested in an if-statement.

97 questions
4
votes
1 answer

.NET Winform Custom Form - Needs to return DialogResult or somehow prevent asynchronous events

I have a form that calls a custom child form. The child form is basically a popup box that gets some user data. I want the Parent form to process information returned by the Child form. The problem is, the Parent form is calling the Child, and…
Tinkerer_CardTracker
  • 3,397
  • 3
  • 18
  • 21
3
votes
2 answers

How to code a switch statement to test DialogResult and provide fall through logic

I'm getting strange results testing the return value from a function. This code is inside a for loop: DialogResult result = EvalReturnFromWS(returnMsg); switch (result) { case DialogResult.Yes: case DialogResult.No: …
John Adams
  • 4,773
  • 25
  • 91
  • 131
3
votes
6 answers

User Control Buttons to Close a Dialog Box

I have created a User Control in my application that has a textbox and then 2 buttons on it. One button is to Add data to the DB from the textbox and the second Cancels the action. This User Control is then added to multiple Dialogs (forms) but I…
Taryn
  • 242,637
  • 56
  • 362
  • 405
3
votes
4 answers

Message box with “Yes”, “No” choices in C#?

I want to make a MessageBox confirmation. Here is the message box: DialogResult dialog = MessageBox.Show("Etes vous sûre de vouloir fermer le programme ?", "Exit",MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { …
Y.Arsoy
  • 129
  • 1
  • 3
  • 10
3
votes
1 answer

Custom C# button's DialogResult doesn't work correctly on modal form

Having a little trouble making a Winforms ImageButton class (C#). My ImageButton class implements the IButtonControl interface but when I add it to a form, and set the button's DialogResult to 'OK' , and then call ShowDialog() on the form, pressing…
2
votes
4 answers

Catching MessageBox result

I'm trying to get the user to confirm if they want to delete a product using a MessageBox and catching its result. This is my code: // Confirm if the user really wants to delete the product DialogResult result = MessageBox.Show("Do you really want…
James Dawson
  • 5,309
  • 20
  • 72
  • 126
2
votes
2 answers

Write code for when the X is clicked on a message box in C#

I writing an application in C# in Visual Studio 2017. I'm using Windows Forms App (.NET Framework). I have a MessageBox pop up with its default settings (only the OK button and the X in the top right corner). When the user selects "OK" the remaining…
Susi
  • 63
  • 7
2
votes
2 answers

DialogResult MessageBox disable Space key (spacebar) from submitting answer

I use the code below to create a MessageBox with dialogue. By default, the yes button has focus. If I press the Space key accidentally, the dialog understands that I selected Yes. I want that only if I press the return key to trigger the event. Is…
Nick_F
  • 1,103
  • 2
  • 13
  • 30
2
votes
1 answer

Efficient way to save Edit Control user input and restore when application restarts C++ Visual Studio

I just got tossed on a project written in C++ on VS. I have a dialog box with Edit Controls where a user enters a MAC address. I would like to save this info when an "on click event" occurs. This is so that when the application exits, this is saved…
2
votes
2 answers

MessageBox continues automatically without pressing on button

I have a messagebox with two buttons and a text. This is the relevant code: var result = MessageBox.Show("just a text","just a…
Itzick Binder
  • 175
  • 1
  • 4
  • 18
2
votes
1 answer

Has setting of DialogResult closing effect on form displayed via ShowDialog()?

After some changes, my application started to behave unexpectedly: login form displayed as If DialogResult.OK <> New frmLogin().ShowDialog() Then ... is automatically closing itself when line marked as 'problem is included. If I comment in out, it…
miroxlav
  • 11,796
  • 5
  • 58
  • 99
2
votes
3 answers

WPF: How to Hide a modal dialog box without destroying it? (its DialogResult)

I've got a modal dialog box and (when user presses its OK button) I want to hide it, show another modal dialog box (MessageBox for example) and then show it back again. My problem is that when the dialog is hidden, its DialogResult gets false and of…
P.W.
  • 657
  • 8
  • 15
2
votes
2 answers

How to code for cancel button in OpenFileDialog box

Whenever I am canceling the OpenFileDialog box. It's giving an error path is empty. My OpenFileDialog box Is there any way I can code for the cancel button and close button of OpenFileDialog My codes: private void button4_Click(object sender,…
2
votes
2 answers

Message box closing form erradically

I use a message box to make sure if the user wants to delete a row from the gridview however no matter what answer they give it closes the form and returns to form1 This is where the viewTransactions form is loaded this code is in Form1 private…
Josh Davis
  • 90
  • 8
2
votes
4 answers

Visual Studio c# DialogResult doesn't seem to work

I'm using visual studio 2010 frmMain has a "Register" button which calls another form newReg This is the code for the button in frmMain that calls the second form. The problem is that the MessageBox("So Far So Good") never gets called. The…
Shane
  • 305
  • 6
  • 16