user386167
user386167

Reputation:

Refreshing a user control in design time depending on a property

I have a custom control with a bool property. In the designer, I drag the user control to a form and I change this property to "false", which is supposed to hide a child control.

It is indeed hiding it in runtime, but not in design time. How could I "refresh" my user control in design time to reflect the changes to this property?

Upvotes: 0

Views: 1425

Answers (3)

user386167
user386167

Reputation:

I'm afraid I didn't ask my question correctly - I was inheriting from a rather complex third-party control and I wanted to see a change in design time.

I ended up overriding OnCreateControl. I appreciate your help nevertheless.

Upvotes: 0

LarsTech
LarsTech

Reputation: 81675

This worked as is using Visual Studio 2012:

public class TestControl : Control {
  Button button;

  public TestControl() {
    button = new Button() { Text = "Click" };
    this.Controls.Add(button);
  }

  public bool ButtonVisible {
    get { return button.Visible; }
    set {
      button.Visible = value;
    }
  }
}

Upvotes: 1

phadaphunk
phadaphunk

Reputation: 13313

I don't know why you want to do this. The Control will only be hidden at runtime and this is how it was meant to be. Maybe you can create something to hide it at Design-Time or add another control over it to hide it.

How could I "refresh" my user control in design time to reflect the changes to this property?

You can't. Changes apply automatically the only reason why you still see it is because that's how it should be.

Upvotes: 1

Related Questions