Using A Class to Convert a String to A Control....
Posted on 2005-03-01
I have a application that I am needing to convert a string to a Control... It is a bunch of pictures that are draging and droping..... I have a couple of examples on how to do it from the form itself but I need to do it from a seperate class. here is the examples that I have so far...
Public Shared Function GetControl1(ByVal ctrlName As String) As Control
For Each ctrl As Control In me.Controls
If ctrl.Name = ctrlName.Trim Then
This one works fine but only from the form.
Public Shared Function GetControl(ByVal IString As String) As Control
GetControl = DirectCast(IString, Control)
I haven't gotten this to work yet but I'm guessing it works fine on the original form to.