Array

lunedì 06 ottobre 2008 - 19.39

netgit Profilo | Newbie

Ciao a tutti.
Sono nuova a VB.net e forse ciò che cerco di fare non si può.
Esempio :
Ho definito questa classe :
Public Class Col_prop
Public Property colVisible() As Boolean
Get
Return p_colVisible
End Get
Set(ByVal value As Boolean)
p_colVisible = value
End Set
End Property
Public Property colWidth() As Integer
Get
Return p_colWidth
End Get
Set(ByVal value As Integer)
p_colWidth = value
End Set
End Property
Public Property colFormat() As Integer
Get
Return p_colFormat
End Get
Set(ByVal value As Integer)
p_colFormat = value
End Set
End Property
Public Property colAlignement() As Integer
Get
Return p_colAlignement
End Get
Set(ByVal value As Integer)
p_colAlignement = value
End Set
End Property
Public Property colSort() As Integer
Get
Return p_colSort
End Get
Set(ByVal value As Integer)
p_colSort = value
End Set
End Property
Dim p_colVisible As New Boolean
Dim p_colWidth As New Integer
Dim p_colFormat As New Integer
Dim p_colAlignement As New Integer
Dim p_colSort As New Integer
Public Sub New()
End Sub
End Class

Poi all'interno di un'altra classe :
Public Class PrintDGV
Dim p_dgv_prop(10) As Col_prop
Public Property DGV_property(ByVal row As Integer) As Col_prop
Get
Return p_dgv_prop(row)
End Get
Set(ByVal value As Col_prop)
p_dgv_prop(row) = value
End Set
End Property
.
.
.
.
Nel MAIN istanzio la PrintDGV
Dim Situ_dgv As New PrintDGV
e tutto va, ma poi quando cerco di settare le :
Situ_dgv.DGV_property(0).colVisible = True
segue l'errore :
Riferimento a un oggetto non impostato su un'istanza di oggetto.

Spero qualcuno sappia dirmi come fare.

Ciao

alx_81 Profilo | Guru

>Ciao a tutti.
Ciao!

>Sono nuova a VB.net e forse ciò che cerco di fare non si può.

>Nel MAIN istanzio la PrintDGV
> Dim Situ_dgv As New PrintDGV
>e tutto va, ma poi quando cerco di settare le :
> Situ_dgv.DGV_property(0).colVisible = True
>segue l'errore :
>Riferimento a un oggetto non impostato su un'istanza di oggetto.
>Spero qualcuno sappia dirmi come fare.
Intranto, utilizza la voce Formatta Codice selezionando il codice da formattare, altrimenti il tuo post risulta illeggebile.
L'errore lo ottieni perchè hai definito un tipo per i tuoi 10 elementi dell'array, ma non hai mai creato gli oggetti.
Cambia questa parte di codice
Situ_dgv.DGV_property(0).colVisible = True

in

Situ_dgv.DGV_property(0) = New Col_prop Situ_dgv.DGV_property(0).colVisible = True

--

Alessandro Alpi | SQL Server MVP

http://www.alessandroalpi.net
http://blogs.dotnethell.it/suxstellino
http://mvp.support.microsoft.com/profile/Alessandro.Alpi
http://italy.mvps.org
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2023
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5