水平滚动条问题
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void hScrollBar1_Scroll(object sender, ScrollEventArgs e)
{
int mysize;
hScrollBar1.Minimum = 5;
hScrollBar1.Maximum = 55;
hScrollBar1.SmallChange = 1;
hScrollBar1.LargeChange = 5;
mysize = hScrollBar1.Value;
textBox1.Font = new System.Drawing.Font( "宋体 ", mysize);
}
}
}
就出现异常
为什么我直接在属性中将Minimum = 5 Maximum = 55
SmallChange = 1 LargeChange = 5
就能够运行呢?
------解决方案--------------------hScrollBar1.Minimum = 5;
hScrollBar1.Maximum = 55;
hScrollBar1.SmallChange = 1;
hScrollBar1.LargeChange = 5;
放到Load事件中