好的,我在VB6版本的表单上有一个Line Control,但是转换在它上面分别创建了一个文件。编译输出有效,但是如果要删除Miscorsoft.VisualBasic.Compatibility,我想要删除4.6+支持的警告,我会没有参考它。
Option Strict Off
Option Explicit On
Imports System.Windows.Forms
Imports System.ComponentModel
Imports Microsoft.VisualBasic.Compatibility.VB6
Imports Microsoft.VisualBasic.PowerPacks
<ProvideProperty("Index", GetType(LineShape))> Friend Class LineShapeArray
Inherits BaseControlArray
Implements IExtenderProvider
Public Event [Click] As EventHandler
Public Sub New()
MyBase.New()
End Sub
Public Sub New(ByVal Container As IContainer)
MyBase.New(Container)
End Sub
Public Function CanExtend(ByVal Target As Object) As Boolean Implements IExtenderProvider.CanExtend
If TypeOf Target Is LineShape Then
Return BaseCanExtend(Target)
End If
Return 0
End Function
Public Function GetIndex(ByVal o As LineShape) As Short
Return BaseGetIndex(o)
End Function
Public Sub SetIndex(ByVal o As LineShape, ByVal Index As Short)
BaseSetIndex(o, Index)
End Sub
Public Function ShouldSerializeIndex(ByVal o As LineShape) As Boolean
Return BaseShouldSerializeIndex(o)
End Function
Public Sub ResetIndex(ByVal o As LineShape)
BaseResetIndex(o)
End Sub
Public Shadows Sub Load(ByVal Index As Short)
MyBase.Load(Index)
CType(Item(0).Parent, ShapeContainer).Shapes.Add(Item(Index))
End Sub
Public Shadows Sub Unload(ByVal Index As Short)
CType(Item(0).Parent, ShapeContainer).Shapes.Remove(Item(Index))
MyBase.Unload(Index)
End Sub
Public Default ReadOnly Property Item(ByVal Index As Short) As LineShape
Get
Item = CType(BaseGetItem(Index), LineShape)
End Get
End Property
Protected Overrides Sub HookUpControlEvents(ByVal o As Object)
Dim ctl As LineShape
ctl = CType(o, LineShape)
If Not IsNothing(ClickEvent) Then
AddHandler ctl.Click, ClickEvent
End If
End Sub
Protected Overrides Function GetControlInstanceType() As System.Type
Return GetType(LineShape)
End Function
End Class
警告:
warning BC40000: 'BaseControlArray' is obsolete: 'Microsoft.VisualBasic.Compatibility.* classes are obsolete and supported within 32 bit processes only. http://go.microsoft.com/fwlink/?linkid=160862'.
警告中的链接实际上并没有帮助修复此警告。
我最终在Form的paint事件中执行此操作,该事件使用了我在下面标记的答案后面的行:
Private Sub Form2_Paint(sender As Object, e As PaintEventArgs) Handles MyBase.Paint
e.Graphics.DrawLine(Pens.Gray, 0, 151, Me.Width, 151)
e.Graphics.DrawLine(Pens.White, 0, 152, Me.Width, 152)
End Sub
y1
中的y2
和DrawLine
值可以替换为所需的表单高度。 Pens
颜色相同。
答案 0 :(得分:2)
答案 1 :(得分:1)
我看到三个问题:控制数组,行控制,使用Microsoft.VisualBasic.Compatibility。
使用FloatingKiwi's answer来避免控制数组。
使用.Net线条绘制方法as explained here替换线条控件。我建议您不要使用Power Pack Line Control,因为不再更新Power Pack。
最好停止使用Microsoft.VisualBasic.Compatibility,以防万一它已经退役,但我个人会考虑让整个项目先运行(如果需要,可以使用Microsoft.VisualBasic.Compatibility),然后寻求删除它。