题目要求:
设计窗体实现以下效果:
2)水平滚动条最小值为4、最大值为72;且在窗体Load事件中通过代码设置;
5)拖动水平滚动条,标签上文字大小发生变化
输入代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace APP
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void hScrollBar1_Scroll(object sender, ScrollEventArgs e)
{
this.linkLabel1.Font = new Font(this.linkLabel1.Font.Name, this.hScrollBar1.Value, this.linkLabel1.Font.Style);
}
private void Form1_Load(object sender, EventArgs e)
{
hScrollBar1.Maximum = 72;
hScrollBar1.Minimum = 4;
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
linkLabel1.Font = new Font(linkLabel1.Font.Name, linkLabel1.Font.Size, checkBox1.Checked ? linkLabel1.Font.Style | FontStyle.Italic : linkLabel1.Font.Style ^ (FontStyle.Italic));
}
private void checkBox1_Click(object sender, EventArgs e)
{
}
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
linkLabel1.Font = new Font(linkLabel1.Font.Name, linkLabel1.Font.Size, checkBox1.Checked ? linkLabel1.Font.Style | FontStyle.Underline : linkLabel1.Font.Style ^ (FontStyle.Underline));
}
private void checkBox3_CheckedChanged(object sender, EventArgs e)
{
linkLabel1.Font = new Font(linkLabel1.Font.Name, linkLabel1.Font.Size, checkBox1.Checked ? linkLabel1.Font.Style | FontStyle.Bold : linkLabel1.Font.Style ^ (FontStyle.Bold));
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
linkLabel1.Font = new Font("黑体", linkLabel1.Font.Size, linkLabel1.Font.Style);
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
linkLabel1.Font = new Font("楷体_GB2312", linkLabel1.Font.Size, linkLabel1.Font.Style);
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
}
private void label1_Click_1(object sender, EventArgs e)
{
}
}
}
运行截图:
总结:
按部就班