滚动条能扭曲图像? 当panel的AutoScroll属性为false时,没有滚动条,图形很对称当panel的AutoScroll属性为true时,有滚动条,图形变了,线条乱七八糟,不对齐请问,是什么原因?如何解决? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 panel1.HorizontalScroll.Visible = false;//横的 panel1.VerticalScroll.Visible = false;//竖的 把你的Panel控制到刚好容下所有控件,设置滚动条每步滚动的像素点。调整到合适大小。如果你的Panel宽度固定的话,可以用%试试 代码是这样的,麻烦帮忙看一下 ,把Panel的AutoScroll属性设置为turepublic partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { Label label; int a = -10; for (int i = 0; i < 1000; i++) { label = new Label(); label.Height = 72; label.Width = 10; label.Top = 0; label.Name = "label" + i.ToString(); a += 10; label.Left = a; panel1.HorizontalScroll.Visible = false; label.Click += buttonN_Click; label.BackColor = Color.Transparent; this.panel1.Controls.Add(label); } } // 画直线 private void panel1_Paint(object sender, PaintEventArgs e) { int a = -10; Graphics graphics = e.Graphics; Pen pen1 = new Pen(Color.Gray, 1); Point point1 = new Point(); Point point2 = new Point(); for (int i = 0; i < 1000; i++) { a += 10; point1.X = a; point1.Y = 0; point2.X = a; point2.Y = 3000; graphics.DrawLine(pen1, point1, point2); } graphics.DrawLine(pen1, 0, 0, 2000, 0); graphics.DrawLine(pen1, 0, 72, 2000, 72); } } 等待答案,我试了一下,把Form窗口最小化,然后恢复,图形又正常了...啥原因 请问,造成这种情况,是不是下面的线条重绘了,而上面的label没有重绘 // 画直线 private void panel1_Paint(object sender, PaintEventArgs e) { for (int i = 0; i < this.panel1.Controls.Count; i++) { Label lb = this.panel1.Controls[i] as Label; if (lb == null) continue; e.Graphics.DrawLine(new Pen(Brushes.Black), lb.Location.X, lb.Location.Y, lb.Location.X, 3000); } e.Graphics.DrawLine(new Pen(Brushes.Black), 0, 0, 2000, 0); e.Graphics.DrawLine(new Pen(Brushes.Black), 0, 72, 2000, 72); } 可以难到大家吗?TCP通讯 类的编写 Visual Studio 2005 和 2008 里面的C# 有什么区别 C# 两个表合并fill到一个dataset中 晕死 我做的项目不见了 怎么可以找到? 添加一个安装的项目,请问如何写里面的卸载功能? 用C#可以调用C的数据结构吗? 解决C#.net调用ice的问题 datagrid 导入到excel表中,如何改变列属性? 过滤掉上下移动的键盘事件 form 读 xml,展示成树 请问穿越控件
panel1.VerticalScroll.Visible = false;//竖的
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Label label;
int a = -10;
for (int i = 0; i < 1000; i++)
{
label = new Label();
label.Height = 72;
label.Width = 10;
label.Top = 0;
label.Name = "label" + i.ToString();
a += 10;
label.Left = a;
panel1.HorizontalScroll.Visible = false;
label.Click += buttonN_Click;
label.BackColor = Color.Transparent;
this.panel1.Controls.Add(label);
}
}
// 画直线
private void panel1_Paint(object sender, PaintEventArgs e)
{
int a = -10;
Graphics graphics = e.Graphics;
Pen pen1 = new Pen(Color.Gray, 1);
Point point1 = new Point();
Point point2 = new Point();
for (int i = 0; i < 1000; i++)
{
a += 10;
point1.X = a;
point1.Y = 0;
point2.X = a;
point2.Y = 3000;
graphics.DrawLine(pen1, point1, point2);
}
graphics.DrawLine(pen1, 0, 0, 2000, 0);
graphics.DrawLine(pen1, 0, 72, 2000, 72);
}
}
// 画直线
private void panel1_Paint(object sender, PaintEventArgs e)
{
for (int i = 0; i < this.panel1.Controls.Count; i++)
{
Label lb = this.panel1.Controls[i] as Label;
if (lb == null)
continue;
e.Graphics.DrawLine(new Pen(Brushes.Black), lb.Location.X, lb.Location.Y,
lb.Location.X, 3000);
}
e.Graphics.DrawLine(new Pen(Brushes.Black), 0, 0, 2000, 0);
e.Graphics.DrawLine(new Pen(Brushes.Black), 0, 72, 2000, 72);
}