public class line inherits system.windows.forms.usercontrol public toplc as system.drawing.color = system.drawing.color.white '上線顏色 public footlc as system.drawing.color = system.drawing.color.black '下線顏色 public linet as type '直線類型 public enum type tf '凸 ft '凹 flat '平面 end enum #region " windows 窗體設計器生成的代碼 " public sub new() mybase.new() '該調用是 windows 窗體設計器所必需的。 initializecomponent() '在 initializecomponent() 調用之后添加任何初始化 end sub 'usercontrol 重寫 dispose 以清理組件列表。 protected overloads overrides sub dispose(byval disposing as boolean) if disposing then if not (components is nothing) then components.dispose() end if end if mybase.dispose(disposing) end sub 'windows 窗體設計器所必需的 private components as system.componentmodel.icontainer '注意: 以下過程是 windows 窗體設計器所必需的 '可以使用 windows 窗體設計器修改此過程。 '不要使用代碼編輯器修改它。 <system.diagnostics.debuggerstepthrough()> private sub initializecomponent() ' 'line ' me.name = "line" me.size = new system.drawing.size(304, 72) end sub #end region #region " 屬性 " <system.componentmodel.description("直線類型:" & vbcrlf & "tf '凸" & vbcrlf & "ft '凹" & vbcrlf & "flat '平面")> public property linetype() as type get linetype = linet end get set(byval value as type) linet = value end set end property <system.componentmodel.description("上線顏色")> public property toplinecolor() as system.drawing.color get toplinecolor = toplc end get set(byval value as system.drawing.color) toplc = value end set end property <system.componentmodel.description("下線顏色")> public property footlinecolor() as system.drawing.color get footlinecolor = footlc end get set(byval value as system.drawing.color) footlc = value end set end property #end region private sub line_paint(byval sender as object, byval e as system.windows.forms.painteventargs) handles mybase.paint dim topline as new pen(me.toplinecolor) dim footline as new pen(me.footlinecolor) dim startx as integer dim starty as integer select case linet case linet.flat e.graphics.drawline(topline, 0 + startx, 0, me.width + startx, 0) e.graphics.drawline(topline, 1 + startx, 1, me.width + startx, 1) case linet.tf e.graphics.drawline(topline, 0 + startx, 0, me.width + startx, 0) e.graphics.drawline(footline, 1 + startx, 1, me.width + startx, 1) case linet.ft e.graphics.drawline(footline, 0 + startx, 0, me.width + startx, 0) e.graphics.drawline(topline, 1 + startx, 1, me.width + startx, 1) end select end sub private sub line_resize(byval sender as object, byval e as system.eventargs) handles mybase.resize me.height = 2 end sub end class