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