Windows Form Fonts Questions Part 1

后端 未结 4 924
小鲜肉
小鲜肉 2020-12-19 16:59

I have some user controls in a windows form. I wonder

  1. if i set the Font property of the main form, will its child get a) a copy of the new

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-19 17:29

    1. Both. The Font property is its own .NET object. Winforms however caches the native Windows font, they are fairly expensive to create. The .NET wrapper object is quite small.

    2. Yes. The code is fine, the Font property setter already disposes the previously assigned font.

    3. Yes, it is disposed by the UserControl. Which in turn is automatically disposed by its parent.

提交回复
热议问题