给自定义组件内数组赋值,请予以帮助,谢谢!!!
该如何修改才能正常赋值,谢谢!!!
Public Class Form5
Private Sub Form5_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Table1.Col = 7
For i As Short = 0 To Table1.Col - 2
Table1.newlist1(i).Name = "GHH" & i‘运行时提示错误
Next
End Sub
End Class
‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’
Public Class Table
Inherits Control
Public Structure NEWtableCell
Dim x1 As Single
Dim x2 As Single
Dim Name As String
End Structure
Private _Col As Short
Public Property Col() As Short
Get
Return _Col
End Get
Set(ByVal Value As Short)
_Col = Value
Refresh()
End Set
End Property
Public newlist1(Col) As NEWtableCell
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
For i = 0 To _Col
Debug.Print(newlist1(i).Name)
Next
End Sub
End Class
------解决方案--------------------------------------------------------
Public Class Form5
Private Sub Form5_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Table1.Col = 7
For i As Short = 0 To Table1.Col - 2
Table1.newlist1(i).Name = "GHH" & i‘运行时提示错误
Next
End Sub
End Class
‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’
Public Class Table
Inherits Control
Public Structure NEWtableCell
Dim x1 As Single
Dim x2 As Single
Dim Name As String
End Structure
Private _Col As Short
Public Property Col() As Short