I didn't see a findcontrolbyname, or a getcontrolbyname function listed.
You could create your own though
public notinheritable class formhelperfunctions
public shared function GetControlbyName(Contianer as Control, Name as
string) as control
'any friend or public control will be found within this control
for each ctrl as control in container.controls
if string.compare(ctrl.name,name) = 0 then
return ctrl
end if
next container
end function
end class
Class Form1
private sub TestMe
dim objControl as control
objControl = formhelperfunctions.getcontrolbyname(me,"Textbox1" )
if not objControl is nothing then
..do work here
else
msgbox("there was applying security, an expected control could not be
found.")
me.customstate = customstateenum.securitycouldnotbeset
exit sub
end if
end sub
End Class
"George Hardy" <sp******************@usmedequip.com> wrote in message
news:er****************@TK2MSFTNGP11.phx.gbl...
hello all,
i am trying to impelement form level security in my vb.net 2003
application.
i have a database table that has the name of the form, subform, userid,
and
read,edit,del,add rights (boolean). The subform is a group box or tabpage
that would be visible or enabled (read or edit rights)
my question is:
I have a security class I pass a form object into. When I try to set the
enabled property or visible property on the group box in question, i get a
run-time exception: "Cast from string "grpInventory" to type 'Integer' is
not valid"
Here is the code in my Security class:
MyForm.Controls(subformname).Enabled = True
So how can I access a control on a passed in form, if i cant do it by
name?
Thanks a bunch!
george hardy