我想在使用拖放操作时在两行之间画一条线。它的功能是简单的可视化,这样用户就知道他要把行放在哪里。该行应该看起来像 excel onces。这是我的代码:
Pen _marqueePen = new Pen(Color.Gray, 2);
float[] dashValues = {1f,1f};
_marqueePen.DashPattern = dashValues;
但这看起来像那样
我想要这样:
我是 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..
}
注意 MSDN 上的文档:
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 像素!
这是结果行:
