Ok so, I had a Line Control on a form on the VB6 Version however the conversion made a file on it separately. The Compiled Output works but it comes with a Warning that I want to remove for 4.6+ support for if Miscorsoft.VisualBasic.Compatibility was to be removed that I would be fine without referencing it.
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
And the Warning:
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'.
And the link in the Warning not actually being Helpful at all to fixing this Warning.
I ended up doing this in the Form's paint event that uses the lines after the Answer to the question below that I marked:
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
The y1
and y2
values in DrawLine
can be replaced to the form height that is wanted. Same for the Pens
Color.
There is no direct equivalent you can use.
I see three issues: control arrays, line control, use of Microsoft.VisualBasic.Compatibility.
Use FloatingKiwi's answer to avoid control arrays.
Replace Line control with .Net line drawing methods as explained here . I recommend you do not use the Power Pack Line Control, since the Power Packs are no longer being updated.
It's a good idea to stop using Microsoft.VisualBasic.Compatibility just in case it is retired, though personally I would consider getting the whole project working first (with Microsoft.VisualBasic.Compatibility if necessary), then seek to remove it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.