473,386 Members | 1,804 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,386 software developers and data experts.

Needto grab the name and position of all buttons on a form -is this possible?

Hi,

In order to save user preferences I need to grab the name and position
of all buttons on a form, which i will then save to a text file. Anyone
know how I can easily get this information?

Thanks
Marc

Nov 24 '06 #1
4 1132

Marc wrote:
Hi,

In order to save user preferences I need to grab the name and position
of all buttons on a form, which i will then save to a text file. Anyone
know how I can easily get this information?

Thanks
Marc
The form has a Controls property that contains all the controls.
Iterate through that and check certain properties of each control to
see if they are the controls you are looking for.
In this case, you might want to take certain actions if you encounter a
control of type Button while iterating through the Controls.

Nov 24 '06 #2
Great...any idea how I access this though?

lord.zol...@gmail.com wrote:
Marc wrote:
Hi,

In order to save user preferences I need to grab the name and position
of all buttons on a form, which i will then save to a text file. Anyone
know how I can easily get this information?

Thanks
Marc

The form has a Controls property that contains all the controls.
Iterate through that and check certain properties of each control to
see if they are the controls you are looking for.
In this case, you might want to take certain actions if you encounter a
control of type Button while iterating through the Controls.
Nov 24 '06 #3

Marc wrote:
Great...any idea how I access this though?
Ok...
First, you've been asking many very basic questions. I think you need
to sit and just read through some basic tutorials or documents. ;)

Now, I'll answer your question ;)
A Form has a property named "Controls". If you have a form named FormA,
you access it by typing "FormA.Controls", or "Me.Controls" if the code
is located in FormA.
"Controls" will return a collection of all the UI controls on the form.
To find all of the buttons on a form, you have to look at the items in
this collection and see which of them are buttons.
You can use the "For Each" loop to do this (I can't explain it all
here, MSDN probably has good documentation on it).
It looks like this:
For each Ctrl As Control in Me.Controls
if TypeOf Ctrl Is Button then
'Do some special button-processing code here.
end if
next

This code represents a loop that looks at each Control in a form's
Controls Collection.
For each of the controls, it check to see if it is a button, and if it
is, you can put your own code in there.
About the syntax:
- "For Each" will iterate through a collection of somethings.
- "Ctrl As Control" will create a new variable named "Ctrl" of type
"Control". "Ctrl" will refer to the object in the collection that is
currently being inspected.
- "in Me.Controls" means you will loop through all of the objects in
"Me.Controls"

Hope this helps.

Nov 24 '06 #4
Yes, thats is a big help! I got it working.

I just need to find a way to read the information back in form the text
file
lord.zol...@gmail.com wrote:
Marc wrote:
Great...any idea how I access this though?

Ok...
First, you've been asking many very basic questions. I think you need
to sit and just read through some basic tutorials or documents. ;)

Now, I'll answer your question ;)
A Form has a property named "Controls". If you have a form named FormA,
you access it by typing "FormA.Controls", or "Me.Controls" if the code
is located in FormA.
"Controls" will return a collection of all the UI controls on the form.
To find all of the buttons on a form, you have to look at the items in
this collection and see which of them are buttons.
You can use the "For Each" loop to do this (I can't explain it all
here, MSDN probably has good documentation on it).
It looks like this:
For each Ctrl As Control in Me.Controls
if TypeOf Ctrl Is Button then
'Do some special button-processing code here.
end if
next

This code represents a loop that looks at each Control in a form's
Controls Collection.
For each of the controls, it check to see if it is a button, and if it
is, you can put your own code in there.
About the syntax:
- "For Each" will iterate through a collection of somethings.
- "Ctrl As Control" will create a new variable named "Ctrl" of type
"Control". "Ctrl" will refer to the object in the collection that is
currently being inspected.
- "in Me.Controls" means you will loop through all of the objects in
"Me.Controls"

Hope this helps.
Nov 24 '06 #5

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

Similar topics

2
by: Jeff | last post by:
I'm trying to create a dynamic form that can have multiple groups of radio buttons (each group has two buttons) with the same name. Essentially, the form allows a user to enter as many names as...
2
by: Visual Systems AB \(Martin Arvidsson\) | last post by:
Hi! Is it possible to modify the text in the MessageBox class? There are a couple of buttons with a standard text. What i want is to set a text of my own. I have inherited the class, but...
3
by: zhouzhendong | last post by:
I have a form that shows a table in single form format. how can I know the position of the record the form is current showing so that I can enable or disable some buttons according to the position...
2
by: Laphan | last post by:
Hi All I have developed a site whereby it uses the contents of a folder (incs gifs, jpgs and css files) to display the web 'skin' of the site. This is OK, but each button on the site is an...
31
by: metaperl | last post by:
-- python -i File "<stdin>", line 1 class = "algebra" ^ SyntaxError: invalid syntax Why isn' t the parser smart enough to see that class followed by an identifier is used for class...
1
by: LaughOutLoud | last post by:
Hi. I wonder is it possible to grab everything in a form by calling one javascript function and turns it into array or object? E.g. <form id="form1" name="form1" method="post" action="">...
1
by: mallz | last post by:
hi, i am retrieving records from databse for display.If there are only 2 records for display, the buttons on my form, say for example, back and exit, keep changing position. For example, if there...
13
by: PhpCool | last post by:
Hi, since sometime I'm stuck in a problem where I want to check or uncheck all the checkboxes. If I'm choosing name for the checkbox array as 'chkbx_ary' then I'm able to check/uncheck all the...
1
by: sandeep kumar shah | last post by:
Hi, We have used a file uploading HTML tag in an HTML page. We need to customize the text displayed on the Button (which is by default “Browse…” for internet explorer). Below is the...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.