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
424
votes
11 answers

How do I create a message box with "Yes", "No" choices and a DialogResult?

I want to make simple Yes/No choiced MessageBox, but I think it is nonsense to design a form for that. I thought I could use MessageBox, add buttons, etc. to accomplish this. It is simple, but since there is no DialogResult returned, how do I…
Petr
  • 7,787
  • 14
  • 44
  • 53
37
votes
2 answers

Using DialogResult Correctly

In an answer to a recent question I had (Here), Hans Passant stated that I should set the DialogResult to close my forms instead of form.Close() although I cannot seem to find out why? If I've read correctly, the MSDN documentation states that doing…
Sayse
  • 42,633
  • 14
  • 77
  • 146
30
votes
10 answers

Can't set DialogResult in WPF

I show a WPF window using ShowDialog() from the calling window. The window opens and is modal as expected. However, in my OK and Cancel button's click events in the dialog window I set this.DialogResult = true (or false) respectively, and the value…
quinnapi
  • 346
  • 1
  • 3
  • 7
19
votes
5 answers

Why is DialogResult a nullable bool in WPF?

Can anyone think of a good explanation for the fact that result of a dialog is a nullable bool in WPF? This has always baffled me. In WinForms it was an enum type and that made a lot more sense to me.
PeterAllenWebb
  • 10,319
  • 3
  • 37
  • 44
18
votes
4 answers

Where is Button.DialogResult in WPF?

In System.Windows.Forms.Button there is a property DialogResult, where is this property in the System.Windows.Controls.Button (WPF)?
Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
12
votes
4 answers

Is it possible to overload the ShowDialog method for forms and return a different result?

EDIT: This method actually works great and I asked it then found the solution later. I added the correct call in the overloaded ShowDialog() method (it's not exacly an overload, or even an override, but it works just the same. My new question is…
Mike Webb
  • 8,855
  • 18
  • 78
  • 111
9
votes
6 answers

Cannot use DialogResult

I tried to use DialogResult to check an Messagebox's YesNoCancel. I'm using the following code which I don't see any problem with: DialogResult dlgResult = MessageBox.Show( "Save changes before closing?", "Warning", …
KMC
  • 19,548
  • 58
  • 164
  • 253
7
votes
3 answers

DialogResult that doesn't close the form?

I have a form Form1 from which I display Form2 as a modal form. From Form2 I do all sort of editing and deleting of different set of values which should be reflected in Form1 after closing Form2. So what I do is RePopulateControls_in_Form1() after…
nawfal
  • 70,104
  • 56
  • 326
  • 368
7
votes
4 answers

DialogResult.OK on SaveFileDialog not work

I try, when I press save in SaveFileDialog I do something. I trying fix but always something wrong. SaveFileDialog dlg2 = new SaveFileDialog(); dlg2.Filter = "xml | *.xml"; dlg2.DefaultExt = "xml"; dlg2.ShowDialog(); if (dlg2.ShowDialog() ==…
user3058140
6
votes
2 answers

Why does ShowDialog always return DialogResult.Cancel?

I have a custom made dialog winform. On it I have a label, textbox and 2 buttons (OK and Cancel). It also declares and defines overloaded execute methods for passing different parameter list. Dialog Winform is called as follows: var theDialog := new…
ThN
  • 3,235
  • 3
  • 57
  • 115
5
votes
2 answers

In VB6 is there something similar to DialogResult from a dialog?

I have a VB6 form with buttons with the text 'Continue' and 'Cancel'. I want to check which one was clicked. In C# every form has a dialog result and I could set it before exiting the form depending on which button was clicked. I don't see this in…
Mike Webb
  • 8,855
  • 18
  • 78
  • 111
5
votes
3 answers

Caliburn Micro: DialogResult

I can't find a solution for the following problem: I open a Dialog with the WindowManager from caliburn micro: public void UserNew() { this._windowManager.ShowDialog(new UserViewModel(this._windowManager)); } Now I need a DialogResult when the…
Timm Bremus
  • 83
  • 1
  • 2
  • 6
4
votes
2 answers

DialogResult problem in wpf

I have a window that I open a few times as a ShowDialog. Every time I open it I use the new keyword in the first time i did: var myWindow = new MyWindow(); myWindow.ShowDialog(); second time I open it from the MyWindow View Model class: new…
Maya
  • 989
  • 4
  • 12
  • 19
4
votes
3 answers

DialogResult can be set only after Window is created and shown as dialog

I have a main WPF window, mywindow.showDialog when a button is clicked on the window, a command is executed let's say the command is SendToTableCommand protected virtual void SendToTableExecute(object o) { UIThread.BeginInvoke(new…
susu
  • 73
  • 1
  • 5
4
votes
2 answers

Closing a form that was opened by ShowDialog()

I have a winform application where I've written my own little color picker that will only display system colours. It's basically a TableLayoutPanel with a bunch of smaller panels added to it, to which I just set the background color. Pretty…
Code Vader
  • 739
  • 3
  • 9
  • 26
1
2 3 4 5 6 7