473,396 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

controls collection

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

Jan 16 '06 #1
2 829
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

Jan 16 '06 #2
thanks! i will give it a try.

george

"AMDRIT" <am****@hotmail.com> wrote in message
news:uu**************@TK2MSFTNGP12.phx.gbl...
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


Jan 17 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: TD | last post by:
This is the code under a command button - Dim ctl As Control For Each ctl In Me.Controls If ctl.BackColor <> RGB(255, 255, 255) Then ctl.BackColor = RGB(255, 255, 255) End If Next ctl
66
by: Cor | last post by:
Hi, I start a new thread about a discussion from yesterday (or for some of us this morning). It was a not so nice discussion about dynamically removing controls from a panel or what ever. It...
6
by: Peter Zolja | last post by:
Hi, I'm building a webcontrol that contains a dynamic list of other controls. My problem is that when I add or remove an item the synchronization between the ViewState and the Controls...
15
by: Arpan | last post by:
Consider the following code which retrieves data from a SQL Server 2005 DB table & displays it in a DataGrid: <script runat="server"> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)...
9
by: dhtml | last post by:
I have written an article "Unsafe Names for HTML Form Controls". <URL: http://jibbering.com/faq/names/ > I would appreciate any reviews, technical or otherwise. Garrett --...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.