动态更改一个Winform中所有控件的字体大小C#
我是C#的新手,目前,我需要在Windows表单中添加动态字体大小更改功能,其中有两个按钮,一个用于增加字体尺寸,另一个用于降低字体大小。
我可以找到的最接近的解决方案是所有控件,就是这篇文章, 如何获取特定类型的Windows表单的所有子女控制(按钮/文本框)?,但是这篇文章是关于获得特定类型的控件,我希望调用所有控件并更改字体大小,无论它们是什么类型。
这个想法甚至可行吗?任何想法都会有所帮助。先感谢您!
I am very new to C#, and currently, I am required to add a dynamic font size changing feature to a Windows Form, where there are two buttons, one for increasing font size, the other one for decreasing font size.
The closest solution I can find for calling all controls is this post,
How to get ALL child controls of a Windows Forms form of a specific type (Button/Textbox)?, but this post is about getting a specific type of control, and I hope to call all controls and change font size no matter what type they are.
Is this thought even feasible? Any thought would be super helpful. Thank you in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我稍后弄清楚我只能使用
this.controls
参考同一Winform中的所有控件I figured out it later that I can just use
this.Controls
to refer to all controls within the same winForm如果要通过单击按钮更改字体大小,则可以参考以下代码:
这是测试结果:
If you want to change font size by click button, you can refer to the following code:
Here is the test result: