Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / December 2006

Tip: Looking for answers? Try searching our database.

Button.Enabled = false causes RadioButton.Click to fire ?? why?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Calvin Willman - 12 Dec 2006 14:47 GMT
I'm working on User Control for a VSTO Excel app, which has 2 radio buttons,
some textboxes, which are displayed, hidden by the radio buttons, and then a
normal button to process user request for a sales report.

The start of the button click looks like...
private void button1_Click(object sender, EventArgs e)
{
try
{
// Disable and Refresh Control for display to User.
label5.Visible = true;
((Button)sender).Enabled = false;     // this.button1.Enabled = false...
also works the same way obviously..
when trying to disabled the button, it fires the radiobutton.changed event,
which causes some problems with the data. If I run it without this line,
everything works fine, although the button is not disabled, which is what we
need really...

I'm really confused... ?? I've set the causes validation property to false
on as many controls as I can find.. but this makes no difference... as I
will need to add validation to the form as well anyway.... any ideas?
Peter Bromley - 12 Dec 2006 20:40 GMT
> I'm working on User Control for a VSTO Excel app, which has 2 radio buttons,
> some textboxes, which are displayed, hidden by the radio buttons, and then a
[quoted text clipped - 17 lines]
> on as many controls as I can find.. but this makes no difference... as I
> will need to add validation to the form as well anyway.... any ideas?

I encountered this about a month ago.

The cause I found was this: the button has focus. When you disable it,
.NET must move the focus, so it moved it (in my case) to the previous
control which was a group of radio buttons. So, the first of the radio
buttons was given focus which fired the Click event. I was surprised too.

I my case I was able to rework my dialog logic to something more
meaningful. Perhaps you can too.

Peter
Calvin Willman - 13 Dec 2006 17:15 GMT
Thanks Peter,

I call .Focus() on a label before disabling the button and that seems to
work a treat... at least it will do for the time being.

Thanks Again.
>> I'm working on User Control for a VSTO Excel app, which has 2 radio
>> buttons, some textboxes, which are displayed, hidden by the radio
[quoted text clipped - 31 lines]
>
> Peter

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.