nik*_*ksn 2 c# graphics pen winforms
我想在使用拖放时在两行之间画一条线。其功能是简单的视觉功能,以便用户知道他将行放在哪里。该行应该看起来像 excel 一次。这是我的代码:
Pen _marqueePen = new Pen(Color.Gray, 2);
float[] dashValues = {1f,1f};
_marqueePen.DashPattern = dashValues;
Run Code Online (Sandbox Code Playgroud)
但这看起来是这样的

我想看起来像这样:

我是WinForms 和C1 Flexgrid控件。
您可以像这样使用自定义笔:
using (Pen pen = new Pen(Color.Gray, 4f) )
{
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
pen.DashPattern = new float[] { 0.25F, 0.25F };
// now draw your stuff..
}
Run Code Online (Sandbox Code Playgroud)
请注意MSDN上的文档:
Run Code Online (Sandbox Code Playgroud)The elements in the dashArray array set the length of each dash and space in the dash pattern. The first element sets the length of a dash, the second element sets the length of a space, the third element sets the length of a dash, and so on. Consequently, each element should be a non-zero positive number. The length of each dash and space in the dash pattern is the product of the element value in the array and the width of the Pen.
您可以选择任何笔宽度以及任何破折号和间隙长度,只要牢记它们的关系即可。因此,如果您想要最精细的破折号,请确保它们乘以 1.0 像素!
这是结果行:

| 归档时间: |
|
| 查看次数: |
4599 次 |
| 最近记录: |