将规则行添加到文本框中的行(多行)

时间:2015-07-08 08:49:28

标签: vb.net visual-studio-2012 textbox multiline

有没有人知道将规则行添加到多行文本框控件的方法?

我正在考虑每行文本下的编写器填充样式淡蓝色线条,填充整个控件。 (不只是在富文本框中键入的内容下划线。)

就像一个空白的大文字框一样,它看起来相当平淡。我认为有人可能知道自定义控件,或者在每个文本行下画一条线的方法。

干杯。

1 个答案:

答案 0 :(得分:0)

只是一个快速的样本,我把它放在一起,应该让你开始:

Public Class Form1

    Private g As Graphics
    Private x As Long
    Private lineHeight As Long

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
        g = Me.CreateGraphics()
        lineHeight = 20
    End Sub

    Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
        g.Dispose()
        g = TextBox1.CreateGraphics()

        For counter As Long = lineHeight To TextBox1.Height Step lineHeight
            g.DrawLine(Pens.LightBlue, 0, counter, TextBox1.Width, counter)
        Next

    End Sub
End Class

我会留下lineHeight的价值,以及如何选择在哪里绘制第一行(另外,不要忘记左边距的垂直规则)

HTH,
埃里克