简体   繁体   中英

Control's region not updating for first time

I have control which i show it as a ToolTip. I have change the size of this control and its region in OnLayout method like below,

protected override void OnLayout(LayoutEventArgs e)
{
   this.Size = calculatedSize;

   Region region= new Region(this.ClientRectangle);

   region.Exclude(new Rectangle(ClientRectangle.Width - balloonPointerWidth, ClientRectangle.Top, balloonPointerWidth, balloonPointerHeight));
   region.Exclude(new Rectangle(ClientRectangle.X, ClientRectangle.Top, ClientRectangle.Width - balloonPointerWidth, balloonPointerHeight));

   this.Region = region;
}

And i have shown the control as ToolTip as mentioned and the modified changes in region are only reflecting at second time showing and the changes are not reflected at first time of showing.

Could anyone please let me know, how to make the changes reflect at first time itself , so that the control as tooltip will be shown with updated regions.?

Regards, Amal Raj U.

You can always call OnLayout directly, eg after loading the form.

protected override void OnLoad(EventArgs e)
{
    //Do whatever setup you had going on before
    base.OnLoad(e);
    OnLayout(e);  //First-time layout
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM