Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - User Control with 2-Dimensional Collection...

Reply
 
Old 03-31-2009   #1 (permalink)
Christiano Donke


 
 

User Control with 2-Dimensional Collection...

I'm trying to implement a 2-dimensional collection into an user control...
This collection should get a param name and a value...

later, the data collected should me read line-by-line (for-each loop) and
the SQLCommand parameters should be created.

The class isn't "holding" the added data.
I don't know how to read this data...

Hints???

Tks in Advance..

What I got so far is:

Public Class UserControl1
Private _Param as List(Of Tipo)
Public Property Param() as List(Of Tipo)
Get
Return _Param
End Get

Set (ByVal value as List(Of Tipo)
_Param = value
End Set
End Property
End Class
Public Class Tipo
Inherits CollectionBase

Private _Param As String
Private _Value As String

Public Property Param() As String
Get
Return _Param
End Get

Set(ByVal value As String)
_Param = value
End Set
End Property

Public Property Value() As String
Get
Return _Value
End Get

Set(ByVal value As String)
_Value = value
End Set
End Property
End Class



My System SpecsSystem Spec
Old 03-31-2009   #2 (permalink)
Family Tree Mike


 
 

RE: User Control with 2-Dimensional Collection...



"Christiano Donke" wrote:
Quote:

> I'm trying to implement a 2-dimensional collection into an user control...
> This collection should get a param name and a value...
>
> later, the data collected should me read line-by-line (for-each loop) and
> the SQLCommand parameters should be created.
>
> The class isn't "holding" the added data.
> I don't know how to read this data...
>
> Hints???
>
> Tks in Advance..
>
> What I got so far is:
>
> Public Class UserControl1
> Private _Param as List(Of Tipo)
> Public Property Param() as List(Of Tipo)
> Get
> Return _Param
> End Get
>
> Set (ByVal value as List(Of Tipo)
> _Param = value
> End Set
> End Property
> End Class
> Public Class Tipo
> Inherits CollectionBase
>
> Private _Param As String
> Private _Value As String
>
> Public Property Param() As String
> Get
> Return _Param
> End Get
>
> Set(ByVal value As String)
> _Param = value
> End Set
> End Property
>
> Public Property Value() As String
> Get
> Return _Value
> End Get
>
> Set(ByVal value As String)
> _Value = value
> End Set
> End Property
> End Class
>
>
Your classes with the following code seem to work fine. What are you trying
that is not behaving correctly?

Sub Main()
Dim uc1 As New UserControl1
Dim listTipo As New List(Of Tipo)
Dim t As New Tipo

uc1.Param = listTipo
t.Param = "Param"
t.Value = "Value"
uc1.Param.Add(t)

t = New Tipo
t.Param = "Gravity"
t.Value = "9.8 m/s/s"

uc1.Param.Add(t)

Console.Out.WriteLine(String.Format("Count: {0}", uc1.Param.Count))
For Each t1 As Tipo In uc1.Param
Console.WriteLine(String.Format("{0} -> {1}", t1.Param, t1.Value))
Next

Console.ReadLine()

' OUTPUT:
' Count: 2
' Param -> Value
' Gravity -> 9.8 m/s/s
End Sub

My System SpecsSystem Spec
Old 04-01-2009   #3 (permalink)
Christiano Donke


 
 

Re: User Control with 2-Dimensional Collection...

As I see it wuld in deed work...

but my problem is placing it in an user control...

i would like to click on the item in the uc property dialog, a popup will
show, and there i'll be able to set both fields...

what i wanna do is something that looks really like the sqlconnection
wizard... which let's you choose the connstring (not needed), write the
connstring, and then assimilate controls to the parameters created....
all through the properties tab...

but it's showing itself harder that i though..


tks again,
chrisitano.

"Family Tree Mike" <FamilyTreeMike@xxxxxx> escreveu na
mensagem news:E5C24245-2478-425D-B00D-24CBF5926448@xxxxxx
Quote:

>
>
> "Christiano Donke" wrote:
>
Quote:

>> I'm trying to implement a 2-dimensional collection into an user
>> control...
>> This collection should get a param name and a value...
>>
>> later, the data collected should me read line-by-line (for-each loop) and
>> the SQLCommand parameters should be created.
>>
>> The class isn't "holding" the added data.
>> I don't know how to read this data...
>>
>> Hints???
>>
>> Tks in Advance..
>>
>> What I got so far is:
>>
>> Public Class UserControl1
>> Private _Param as List(Of Tipo)
>> Public Property Param() as List(Of Tipo)
>> Get
>> Return _Param
>> End Get
>>
>> Set (ByVal value as List(Of Tipo)
>> _Param = value
>> End Set
>> End Property
>> End Class
>> Public Class Tipo
>> Inherits CollectionBase
>>
>> Private _Param As String
>> Private _Value As String
>>
>> Public Property Param() As String
>> Get
>> Return _Param
>> End Get
>>
>> Set(ByVal value As String)
>> _Param = value
>> End Set
>> End Property
>>
>> Public Property Value() As String
>> Get
>> Return _Value
>> End Get
>>
>> Set(ByVal value As String)
>> _Value = value
>> End Set
>> End Property
>> End Class
>>
>>
>
> Your classes with the following code seem to work fine. What are you
> trying
> that is not behaving correctly?
>
> Sub Main()
> Dim uc1 As New UserControl1
> Dim listTipo As New List(Of Tipo)
> Dim t As New Tipo
>
> uc1.Param = listTipo
> t.Param = "Param"
> t.Value = "Value"
> uc1.Param.Add(t)
>
> t = New Tipo
> t.Param = "Gravity"
> t.Value = "9.8 m/s/s"
>
> uc1.Param.Add(t)
>
> Console.Out.WriteLine(String.Format("Count: {0}", uc1.Param.Count))
> For Each t1 As Tipo In uc1.Param
> Console.WriteLine(String.Format("{0} -> {1}", t1.Param, t1.Value))
> Next
>
> Console.ReadLine()
>
> ' OUTPUT:
> ' Count: 2
> ' Param -> Value
> ' Gravity -> 9.8 m/s/s
> End Sub
>

My System SpecsSystem Spec
Old 04-01-2009   #4 (permalink)
Christiano Donke


 
 

Re: User Control with 2-Dimensional Collection...

Amost there...

In the UC class created this sub:
Dim listTipo As New List(Of Tipo)


Public Sub ParaAdd(ByVal Param As String, ByVal Value As String)
Dim p As New Tipo
p.Param = Param
p.Value = Value
listTipo.Add(p)
End Sub

It's working... It's collection the params and values and keeping them.. but
I can reach this sub only via code...
Can I, somehow, access it though the property panel?



tks once again...



"Christiano Donke" <cdonke@xxxxxx> escreveu na mensagem
news:%23PacbqusJHA.5912@xxxxxx
Quote:

> As I see it wuld in deed work...
>
> but my problem is placing it in an user control...
>
> i would like to click on the item in the uc property dialog, a popup will
> show, and there i'll be able to set both fields...
>
> what i wanna do is something that looks really like the sqlconnection
> wizard... which let's you choose the connstring (not needed), write the
> connstring, and then assimilate controls to the parameters created....
> all through the properties tab...
>
> but it's showing itself harder that i though..
>
>
> tks again,
> chrisitano.
>
> "Family Tree Mike" <FamilyTreeMike@xxxxxx> escreveu na
> mensagem news:E5C24245-2478-425D-B00D-24CBF5926448@xxxxxx
Quote:

>>
>>
>> "Christiano Donke" wrote:
>>
Quote:

>>> I'm trying to implement a 2-dimensional collection into an user
>>> control...
>>> This collection should get a param name and a value...
>>>
>>> later, the data collected should me read line-by-line (for-each loop)
>>> and
>>> the SQLCommand parameters should be created.
>>>
>>> The class isn't "holding" the added data.
>>> I don't know how to read this data...
>>>
>>> Hints???
>>>
>>> Tks in Advance..
>>>
>>> What I got so far is:
>>>
>>> Public Class UserControl1
>>> Private _Param as List(Of Tipo)
>>> Public Property Param() as List(Of Tipo)
>>> Get
>>> Return _Param
>>> End Get
>>>
>>> Set (ByVal value as List(Of Tipo)
>>> _Param = value
>>> End Set
>>> End Property
>>> End Class
>>> Public Class Tipo
>>> Inherits CollectionBase
>>>
>>> Private _Param As String
>>> Private _Value As String
>>>
>>> Public Property Param() As String
>>> Get
>>> Return _Param
>>> End Get
>>>
>>> Set(ByVal value As String)
>>> _Param = value
>>> End Set
>>> End Property
>>>
>>> Public Property Value() As String
>>> Get
>>> Return _Value
>>> End Get
>>>
>>> Set(ByVal value As String)
>>> _Value = value
>>> End Set
>>> End Property
>>> End Class
>>>
>>>
>>
>> Your classes with the following code seem to work fine. What are you
>> trying
>> that is not behaving correctly?
>>
>> Sub Main()
>> Dim uc1 As New UserControl1
>> Dim listTipo As New List(Of Tipo)
>> Dim t As New Tipo
>>
>> uc1.Param = listTipo
>> t.Param = "Param"
>> t.Value = "Value"
>> uc1.Param.Add(t)
>>
>> t = New Tipo
>> t.Param = "Gravity"
>> t.Value = "9.8 m/s/s"
>>
>> uc1.Param.Add(t)
>>
>> Console.Out.WriteLine(String.Format("Count: {0}", uc1.Param.Count))
>> For Each t1 As Tipo In uc1.Param
>> Console.WriteLine(String.Format("{0} -> {1}", t1.Param, t1.Value))
>> Next
>>
>> Console.ReadLine()
>>
>> ' OUTPUT:
>> ' Count: 2
>> ' Param -> Value
>> ' Gravity -> 9.8 m/s/s
>> End Sub
>>
>
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
dont know user account control password and no administrator user General Discussion
2 dimensional array of objects VB Script
Control the Maximum allowed User Sessions in Fast User Switching Vista General
Multi-dimensional arrays PowerShell
How to set "Run as" user for logman collection PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46