根据窗口大小调整表单的标签和字体大小 [英] Resizing a label and Font of the form based on the window sizing
本文介绍了根据窗口大小调整表单的标签和字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻求帮助,根据其窗口大小调整标签的大小和字体大小.
I'm looking for help resizing a label's size and its font size based on its window size.
也就是说,当窗口调整大小时,标签本身会调整它的字体和背景框以执行相同的操作.
That's to say when a window resizes, the label itself adjusts it font and background box to do the same.
我知道我触发了表单的 Resize 事件,但我不知道是什么.有人可以帮忙吗?
I know I'm triggering something on the Resize event of the form, but I don't know what. Can anyone help?
推荐答案
这是在 C# 中,但它可能对您有所帮助.
This is in C# but it might help you.
public Form1()
{
InitializeComponent();
this.Resize += new EventHandler(Form1_Resize);
label1.AutoSize = false;
label1.Size = new Size(100, 50);
label1.BackColor = Color.White;
}
void Form1_Resize(object sender, EventArgs e)
{
label1.Size = new Size(this.ClientSize.Width / 3, this.ClientSize.Height / 3);
label1.Font = new Font("Arial", this.ClientSize.Height / 20);
}
这篇关于根据窗口大小调整表单的标签和字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文