2021年3月3日星期三

User control and anchor issues

I know that the question has probably been asked already, I've been googling it up but could not find any suitable answer (english is a second language for me), so I aplogize in advance.

So I created a basic user control that inherits from a Panel and I do the painting manually. It consists of displaying a list of "items", acting like an overlay. Sort of. Right now, the width is static, but the height depends on the numbers of items I want to display. I've have no issue resizing the control to the size it has to have when the collection of item is refreshed.

My problem is : I'd like it to be "docked", on the to bottom right corner of my main form. But using anchor bottom and right isn't working. It's pretty similar to this screenshot : GUI Anchor property issue

I tried this :

    protected override void OnSizeChanged(EventArgs e)      {          if(Handle != null)              _ = BeginInvoke((MethodInvoker)delegate { base.OnSizeChanged(e); });      }  

but it doesn't work either. What is the most easiest way to achieve it ? I know that the main form could it, but looks like a dirty design to me.

Also, I plan to override the MouseMove. I read that I could affect the resize as well.

Any advice / links would be much appreciated !

Thanks !

https://stackoverflow.com/questions/66467149/user-control-and-anchor-issues March 04, 2021 at 09:07AM

没有评论:

发表评论