Torna al Thread

Se l'argomento nella firma del metodo è dichiarato come tipo Form ..... Public Sub Procedi(ByVal Contenitore As Windows.Forms.Form) .... non è necessario convertirlo in Form perchè è già tipizzato a dovere Dim frm As Form = CType(Contenitore, Form) For Each cnt As Control In frm.Controls If TypeOf cnt Is Panel Then For Each _cnt As Control In cnt.Controls If _cnt.Name = "Button2" Then la classe Control(dal quale deriva il tipo Button e tutti gli altri controlli) ha già di suo una proprietà Text...... DirectCast(_cnt, Button).Text = "Pippo" Quindi avresti potruto semplicemente scrivere .... _cnt.Text="Pippo" End If Next End If Next End Sub
Copyright © dotNetHell.it 2002-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5