0

我遇到了麻烦,无法找到出路

我正在尝试单击一个按钮,然后让用户在文本框 7 和 8 中输入输入,然后重用文本框 7 和 8 来获取接下来的两个值,一旦完成,线条就被绘制了…… </p>

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
    Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)
    Dim formGraphics As System.Drawing.Graphics

    Dim x1 As Integer
    Dim y1 As Integer
    Dim x2 As Integer
    Dim y2 As Integer

    x1 = TextBox7.Text
    y1 = TextBox8.Text

    'clears textbox values...
    TextBox7.Text = ""
    TextBox8.Text = ""

    'set focus to textbox7...
    TextBox7.Focus()

    x2 = TextBox7.Text
    y2 = TextBox8.Text

    formGraphics = Me.CreateGraphics()
    formGraphics.DrawLine(myPen, x1, y1, x2, y2)
    myPen.Dispose()
    formGraphics.Dispose()
End Sub

目前,在单击按钮之前需要先填充文本框,我希望它反过来..

有人知道怎么做吗?

使用 VB.net...

4

1 回答 1

0

您是否要处理文本框 textchanged 事件,以便每当文本框中的文本发生更改时,您都可以检查它是否满足您的条件?

http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.textboxbase.textchanged.aspx

您还需要将代码分解为几个不同的子例程

于 2013-04-25T08:41:46.560 回答