Trum
Trum

Reputation: 71

Display/Shown event for User Control

I want to popup/show a dialog when ever my user control is displayed/shown. But I couldn't find any such event. What options do I have and what would I have to do to implement it myself?

I'm using DevExpress XtraUserControl.

Thanks.

Upvotes: 2

Views: 4394

Answers (1)

Jan
Jan

Reputation: 2168

Register to the Activated event of the main form.

public Form1()
{
    InitializeComponent();
    this.Activated +=new EventHandler(Form1_GotFocus);
}

public void Form1_GotFocus(object sender, EventArgs e)
{
    //your payload here
}

Note that if you close a dialog and return to the form, the event is fired again.

Upvotes: 1

Related Questions