Dim x As Integer = CInt(e.Form.Controls("矩形起点X").Value)
Dim y As Integer = CInt(e.Form.Controls("矩形起点Y").Value)
Dim jk As Integer = CInt(e.Form.Controls("矩形宽").Value)
Dim jg As Integer = CInt(e.Form.Controls("矩形高").Value)
Dim p As WinForm.Painter = e.Form.Controls("Painter1")
Dim g As Graphics = p.Graphics
Dim ys As Color = e.Form.Controls("颜色").Color
Dim pn As New Pen(ys, e.Form.Controls("线宽").value)
Dim ds = CInt(e.Form.Controls("线型").value) 'e.Form.Controls("线型").value
pn.DashStyle =ds
'DashStyle.DashDotDot(此为复制控件Controls("线型")中显示的值)
g.DrawRectangle(pn,x,y,jk,jg)
p.Repaint()
上面一段代码,红色代码部分会报错:
从字符串“DashStyle.DashDotDot”到类型“Integer" 转换无效
但是将其中的ds更换为后面注释的DashStyle.DashDotDot后却不会报错,而这个字符串正是刚才报错时控件中输入的字符串!
而将蓝字部分更换为它后面注释掉的代码仍会报错。
百思不得其解,求教!