本文介绍了C#画线并调整表格形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码

This is my code

private void panel1_Paint(object sender, PaintEventArgs e)
{
   float[] dashValues = { 2, 5, 2, 5 };
   Pen blackPen = new Pen(Color.Black, 2);
   blackPen.DashPattern = dashValues;
   e.Graphics.DrawLine(blackPen, new Point(panel1.Width, panel1.Height),
                       new Point(0, panel1.Height));
}



并且panel1固定在左,右


this is my problem, when i size this form very slowly the dashes become very close together and don''t leave a gap like it is supposed to

例如在调整大小时
看起来像什么:----

它最终看起来像:----



and panel1 is anchored left,right


this is my problem, when i size this form very slowly the dashes become very close together and don''t leave a gap like it is supposed to

for example when re-sizing
what is meant to look like: - - - -

it ends up looking like: ----

推荐答案

private void panel1_Resize(object sender, EventArgs e)
{
    panel1.Invalidate();
}



这篇关于C#画线并调整表格形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 14:26