Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cloning combobox
Message
From
12/06/2012 10:36:16
 
 
To
12/06/2012 08:53:50
General information
Forum:
ASP.NET
Category:
Forms
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01544151
Message ID:
01545880
Views:
36
sorry, misread... check that SelectedIndex is the ***last*** property to set in the loop.
SWAG: SelectedIndex is set before a Datasource exists...

>Ok, here is what I have:
>
>
>    ' Clone a control
>    ' expO1 Control
>    Public Function CloneControl(toControl As System.Windows.Forms.Control) As System.Windows.Forms.Control
>        Dim loClone As System.Windows.Forms.Control = Nothing
>
>        ' Initialization
>        loClone = DirectCast(Activator.CreateInstance(toControl.[GetType]()), System.Windows.Forms.Control)
>
>        ' For each property
>        For Each [property] As System.ComponentModel.PropertyDescriptor In System.ComponentModel.TypeDescriptor.GetProperties(toControl)
>
>            ' If this property is serializable
>            If [property].PropertyType.IsSerializable Then
>                [property].SetValue(loClone, [property].GetValue(toControl))
>            End If
>
>        Next
>
>        Return loClone
>    End Function
>
>
>This is the code that is cloning and the previous code:
>
>
>        ' Those two are equivalent
>        NoCountryTax2 = CloneControl(NoCountryTax)
>        NoProvinceTax2 = CloneControl(NoProvinceTax)
>
>        If False Then
>            NoCountryTax2.DataSource = NoCountryTax.DataSource
>            NoCountryTax2.DisplayMember = NoCountryTax.DisplayMember
>            NoCountryTax2.ValueMember = NoCountryTax.ValueMember
>            NoCountryTax2.SelectedIndex = NoCountryTax.SelectedIndex
>            NoProvinceTax2.DataSource = NoProvinceTax.DataSource
>            NoProvinceTax2.DisplayMember = NoProvinceTax.DisplayMember
>            NoProvinceTax2.ValueMember = NoProvinceTax.ValueMember
>            NoProvinceTax2.SelectedIndex = NoProvinceTax.SelectedIndex
>        End If
>
>
>This gives this error:
>
>InvalidArgument=Value of '28' is not valid for 'SelectedIndex'.
>Parameter name: Selected Index.
>
>Is this because the SelectedIndex cannot be clone?
Previous
Reply
Map
View

Click here to load this message in the networking platform