PC Review


Reply
Thread Tools Rate Thread

Click event not raised when clicking a button after displaying a dialog box

 
 
Natalya.Pinsker@constellation.com
Guest
Posts: n/a
 
      5th Dec 2006
Hello,

In the Validating event of a TextBox, I am displaying a Yes/No message
box. If clicked on No, I cancel any subsequent events. This works
just fine. If clicked Yes, I want to go on. This doesn't work if I
click on a button (like a Save button). The focus stays with the Save
button after clicking Yes, but the click event for the Save button
doesn't fire.

I've pasted the condensed version of my code below. As a work around,
I tried setting "this.ActiveControl = this.ActiveControl;" but it had
no effect. This was suggested for a somewhat different problem by an
older post:
http://groups.google.com/group/micro...8f5e8058e96ef0

private void txtQty_Validating(object sender,
System.ComponentModel.CancelEventArgs e)
{
if (Convert.ToInt32(txtQty.Text) == 0)
{
if (MessageBox.Show("Are you sure you want quantity set
to zero?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
== DialogResult.Yes)
{
//this.ActiveControl = this.ActiveControl;
}
else
{
e.Cancel = true;
}
}
}

I use VS2003.

Thanks.

 
Reply With Quote
 
 
 
 
=?Utf-8?B?TUtpbg==?=
Guest
Posts: n/a
 
      5th Dec 2006
Why not just call the Save event method directly if the dialog result answer
is "Yes"?

MK

"(E-Mail Removed)" wrote:

> Hello,
>
> In the Validating event of a TextBox, I am displaying a Yes/No message
> box. If clicked on No, I cancel any subsequent events. This works
> just fine. If clicked Yes, I want to go on. This doesn't work if I
> click on a button (like a Save button). The focus stays with the Save
> button after clicking Yes, but the click event for the Save button
> doesn't fire.
>
> I've pasted the condensed version of my code below. As a work around,
> I tried setting "this.ActiveControl = this.ActiveControl;" but it had
> no effect. This was suggested for a somewhat different problem by an
> older post:
> http://groups.google.com/group/micro...8f5e8058e96ef0
>
> private void txtQty_Validating(object sender,
> System.ComponentModel.CancelEventArgs e)
> {
> if (Convert.ToInt32(txtQty.Text) == 0)
> {
> if (MessageBox.Show("Are you sure you want quantity set
> to zero?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
> == DialogResult.Yes)
> {
> //this.ActiveControl = this.ActiveControl;
> }
> else
> {
> e.Cancel = true;
> }
> }
> }
>
> I use VS2003.
>
> Thanks.
>
>

 
Reply With Quote
 
NP
Guest
Posts: n/a
 
      5th Dec 2006
It doesn't have to be the Save button. In fact, it can be any button
on the form, including buttons in this or other user controls.

Is this a problem with .NET framework?

Thanks,
NP



MKin wrote:
> Why not just call the Save event method directly if the dialog result answer
> is "Yes"?
>
> MK
>
> > Hello,
> >
> > In the Validating event of a TextBox, I am displaying a Yes/No message
> > box. If clicked on No, I cancel any subsequent events. This works
> > just fine. If clicked Yes, I want to go on. This doesn't work if I
> > click on a button (like a Save button). The focus stays with the Save
> > button after clicking Yes, but the click event for the Save button
> > doesn't fire.
> >
> > I've pasted the condensed version of my code below. As a work around,
> > I tried setting "this.ActiveControl = this.ActiveControl;" but it had
> > no effect. This was suggested for a somewhat different problem by an
> > older post:
> > http://groups.google.com/group/micro...8f5e8058e96ef0
> >
> > private void txtQty_Validating(object sender,
> > System.ComponentModel.CancelEventArgs e)
> > {
> > if (Convert.ToInt32(txtQty.Text) == 0)
> > {
> > if (MessageBox.Show("Are you sure you want quantity set
> > to zero?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
> > == DialogResult.Yes)
> > {
> > //this.ActiveControl = this.ActiveControl;
> > }
> > else
> > {
> > e.Cancel = true;
> > }
> > }
> > }
> >
> > I use VS2003.
> >
> > Thanks.
> >
> >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Button.Click event doesn't fire when clicking button in formView.InsertItemTemplate Andy B. Microsoft ASP .NET 0 25th Nov 2009 03:27 PM
RadioButton: the Click event was raised unproperly =?Utf-8?B?U21hbGxkdXN0?= Microsoft Dot NET Framework Forms 6 18th Oct 2005 01:08 PM
How-to exit button click event of ( C#) modal dialog without exiting dialog? Lew Barnesson Microsoft Dot NET Framework Forms 3 2nd Jun 2005 11:03 PM
Click event don't be raised on a TextBox Paulo Costa Microsoft Dot NET Compact Framework 10 21st Jan 2005 01:31 PM
Please help : Click event not raised when clicking button!!! Pascal Microsoft Dot NET Framework Forms 4 24th Mar 2004 08:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:29 AM.