Click here to Skip to main content
15,897,704 members
Home / Discussions / C#
   

C#

 
QuestionHow to include a DialogBox in a C#.Net at design time. Pin
AmarjeetSinghMatharu22-Jul-07 21:39
AmarjeetSinghMatharu22-Jul-07 21:39 
AnswerRe: How to include a DialogBox in a C#.Net at design time. Pin
satsumatable23-Jul-07 0:36
satsumatable23-Jul-07 0:36 
GeneralRe: How to include a DialogBox in a C#.Net at design time. Pin
AmarjeetSinghMatharu24-Jul-07 23:39
AmarjeetSinghMatharu24-Jul-07 23:39 
Questionusing settings Pin
baelzaden22-Jul-07 21:06
baelzaden22-Jul-07 21:06 
AnswerRe: using settings Pin
Guffa22-Jul-07 22:39
Guffa22-Jul-07 22:39 
AnswerRe: using settings Pin
ekynox22-Jul-07 22:47
ekynox22-Jul-07 22:47 
QuestionControl Box Close Button Event Pin
VenkataRamana.Gali22-Jul-07 20:58
VenkataRamana.Gali22-Jul-07 20:58 
AnswerRe: Control Box Close Button Event Pin
Martin#22-Jul-07 21:30
Martin#22-Jul-07 21:30 
Hello,

In your CancelButton code (Click event handler), you could set the DialogResult property of the Form to DialogResult.Cancel.
So if the user Closes the Form over the 'X', the Default would be DialogResult.None.

private void CancelButton_Click(object sender, System.EventArgs e)
{
    this.DialogResult = DialogResult.Cancel;
    this.Close();
}

protected override void OnClosing(CancelEventArgs e)
{
    if(this.DialogResult == DialogResult.None)
    {
        //Comes from X
    }
    else if(this.DialogResult == DialogResult.Cancel)
    {
        //Comes from CancelButton
    }

    base.OnClosing (e);
}


Hope it helps!

All the best,

Martin

GeneralRe: Control Box Close Button Event Pin
VenkataRamana.Gali22-Jul-07 22:44
VenkataRamana.Gali22-Jul-07 22:44 
GeneralRe: Control Box Close Button Event Pin
Martin#22-Jul-07 22:46
Martin#22-Jul-07 22:46 
GeneralRe: Control Box Close Button Event Pin
VenkataRamana.Gali22-Jul-07 22:55
VenkataRamana.Gali22-Jul-07 22:55 
GeneralRe: Control Box Close Button Event Pin
Martin#22-Jul-07 23:01
Martin#22-Jul-07 23:01 
GeneralRe: Control Box Close Button Event Pin
VenkataRamana.Gali22-Jul-07 23:15
VenkataRamana.Gali22-Jul-07 23:15 
GeneralRe: Control Box Close Button Event Pin
Martin#22-Jul-07 23:24
Martin#22-Jul-07 23:24 
GeneralRe: Control Box Close Button Event Pin
Luc Pattyn23-Jul-07 2:17
sitebuilderLuc Pattyn23-Jul-07 2:17 
GeneralRe: Control Box Close Button Event Pin
Martin#23-Jul-07 2:41
Martin#23-Jul-07 2:41 
GeneralRe: Control Box Close Button Event Pin
Luc Pattyn23-Jul-07 3:07
sitebuilderLuc Pattyn23-Jul-07 3:07 
GeneralRe: Control Box Close Button Event Pin
Martin#23-Jul-07 3:09
Martin#23-Jul-07 3:09 
GeneralRe: Control Box Close Button Event Pin
Luc Pattyn23-Jul-07 3:30
sitebuilderLuc Pattyn23-Jul-07 3:30 
GeneralRe: Control Box Close Button Event Pin
Martin#23-Jul-07 3:43
Martin#23-Jul-07 3:43 
GeneralRe: Control Box Close Button Event Pin
Luc Pattyn23-Jul-07 4:02
sitebuilderLuc Pattyn23-Jul-07 4:02 
GeneralRe: Control Box Close Button Event Pin
Martin#23-Jul-07 4:13
Martin#23-Jul-07 4:13 
GeneralRe: Control Box Close Button Event Pin
Luc Pattyn23-Jul-07 4:13
sitebuilderLuc Pattyn23-Jul-07 4:13 
GeneralRe: Control Box Close Button Event Pin
Martin#23-Jul-07 4:20
Martin#23-Jul-07 4:20 
GeneralRe: Control Box Close Button Event Pin
Luc Pattyn23-Jul-07 4:41
sitebuilderLuc Pattyn23-Jul-07 4:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.