Change visible state for a Button

  • Thread starter Thread starter Geoffrey
  • Start date Start date
G

Geoffrey

Hello,

On a form, I place a buton with an OnClick event. No problem.

I set the visible propperty of this button to false.
And reset it so true again, the event isn't fired ans my app same to be
crashed ...

Any idea?

Thx
 
Can you clarify?
On a form, I place a buton with an OnClick event.
Do you mean that you subscribe to the Click event?
the event isn't fired
Do you mean that subsequently clicking the Button has no effect?
my app same to be crashed ...
In what way?

What framework version? (1.1, 2.0?)

Are you doing anything unusual? threading?

The following works fine:

static void Main() {
using (Form f = new Form())
using (Button b1 = new Button())
using (Button b2 = new Button()) {
b1.Text = "Toggle visible";
b2.Text = "Click me";
b1.Click += delegate { b2.Visible = !b2.Visible; };
b2.Click += delegate { f.Text += " [click]"; };
b1.Dock = b2.Dock = DockStyle.Top;
f.Controls.AddRange(new Control[] {b2, b1});
Application.Run(f);
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top