473,472 Members | 2,184 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

change parameters of all text

is it possible to change a setting, such as Forecolor for all text in a
form, or do you have to change it for each text block?
Dec 28 '05 #1
9 1410
matt wrote:
is it possible to change a setting, such as Forecolor for all text in a
form, or do you have to change it for each text block?


Find and replace.

Find ".ForeColor = "
Replace ".ForeColor = NewForeColor '"

Chris
Dec 28 '05 #2

"Chris" <no@spam.com> wrote in message
news:ut**************@TK2MSFTNGP12.phx.gbl...
matt wrote:
is it possible to change a setting, such as Forecolor for all text in a
form, or do you have to change it for each text block?


Find and replace.

Find ".ForeColor = "
Replace ".ForeColor = NewForeColor '"

hey, thanks for the reply. sorry for not being clear, i mean change it in
the code from its default settings in the form. for instance. i have 5 text
labels, lbl1...lbl5. all have default settings of black text, and i want to
change the text color to orange. i would do

lbl1.forecolor = colorsetting
lbl2.forecolor = colorsetting
....
lbl5.forecolor = colorsetting

is there an easy way to change a parmeter? like

new something = lbl1 ... lbl5

something.forecolor = colorsetting
Just a thought that i wanted to ask about. Thanks!
Dec 28 '05 #3
I don't think so. But, the whole thing can be shortened as:
For Each c As Control In Me.Controls

If TypeOf (c) Is Label Then

DirectCast(c, Label).ForeColor = Color.Coral

End If

Next

"matt" <no****@nobody.com> wrote in message
news:LL********************@comcast.com...

"Chris" <no@spam.com> wrote in message
news:ut**************@TK2MSFTNGP12.phx.gbl...
matt wrote:
is it possible to change a setting, such as Forecolor for all text in a
form, or do you have to change it for each text block?


Find and replace.

Find ".ForeColor = "
Replace ".ForeColor = NewForeColor '"

hey, thanks for the reply. sorry for not being clear, i mean change it in
the code from its default settings in the form. for instance. i have 5 text
labels, lbl1...lbl5. all have default settings of black text, and i want to
change the text color to orange. i would do

lbl1.forecolor = colorsetting
lbl2.forecolor = colorsetting
....
lbl5.forecolor = colorsetting

is there an easy way to change a parmeter? like

new something = lbl1 ... lbl5

something.forecolor = colorsetting
Just a thought that i wanted to ask about. Thanks!

Dec 29 '05 #4
"Siva M" <sh******@online.excite.com> wrote in message
news:Or**************@TK2MSFTNGP12.phx.gbl...
I don't think so. But, the whole thing can be shortened as:
For Each c As Control In Me.Controls

If TypeOf (c) Is Label Then

DirectCast(c, Label).ForeColor = Color.Coral

End If

Next


This is great, and is basically what i was going for. However, i tried
putting it into my code and it isn't working correctly. I see that it goes
into the for loop, but only once, it isn't looping through all of the
properties. any ideas?

thanks,
Dec 29 '05 #5
Shiva
I don't think so. But, the whole thing can be shortened as:
For Each c As Control In Me.Controls

If TypeOf (c) Is Label Then

DirectCast(c, Label).ForeColor = Color.Coral

End If

Next


This is great, and is basically what i was going for. However, i tried
putting it into my code and it isn't working correctly. I see that it
goes into the for loop, but only once, it isn't looping through all of the
properties. any ideas?

Probably because that you have controls in controls. This is easy to
overcome by doing this recursive.

\\\
SetColors(me)
Public sub SetColors(byval this as controls)
For Each c As Control In This.Controls
If TypeOf (c) Is Label Then
DirectCast(c, Label).ForeColor = Color.Coral
End If
SetColors(c)
Next
///
Watch typos it is changed in this message.

I hope this helps,

Cor
Dec 29 '05 #6
Matt/Shiva,

Shiva had to be Matt.

Cor
Dec 29 '05 #7
It looks like you have only one Label on the form. As Cor has said, use
recursion to check container controls as well on the form

"matt" <no****@nobody.com> wrote in message
news:l6********************@comcast.com...
"Siva M" <sh******@online.excite.com> wrote in message
news:Or**************@TK2MSFTNGP12.phx.gbl...
I don't think so. But, the whole thing can be shortened as:
For Each c As Control In Me.Controls

If TypeOf (c) Is Label Then

DirectCast(c, Label).ForeColor = Color.Coral

End If

Next


This is great, and is basically what i was going for. However, i tried
putting it into my code and it isn't working correctly. I see that it goes
into the for loop, but only once, it isn't looping through all of the
properties. any ideas?

thanks,

Dec 29 '05 #8
"matt" <no****@nobody.com> schrieb:
is it possible to change a setting, such as Forecolor for all text in a
form, or do you have to change it for each text block?


You may find this class useful:

<URL:http://dotnet.mvps.org/dotnet/samples/controls/EnumerateControls.zip>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Dec 29 '05 #9

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:O2**************@TK2MSFTNGP14.phx.gbl...
Shiva
I don't think so. But, the whole thing can be shortened as:
For Each c As Control In Me.Controls

If TypeOf (c) Is Label Then

DirectCast(c, Label).ForeColor = Color.Coral

End If

Next


This is great, and is basically what i was going for. However, i tried
putting it into my code and it isn't working correctly. I see that it
goes into the for loop, but only once, it isn't looping through all of
the properties. any ideas?

Probably because that you have controls in controls. This is easy to
overcome by doing this recursive.

\\\
SetColors(me)
Public sub SetColors(byval this as controls)
For Each c As Control In This.Controls
If TypeOf (c) Is Label Then
DirectCast(c, Label).ForeColor = Color.Coral
End If
SetColors(c)
Next
///
Watch typos it is changed in this message.

I hope this helps,

Works great! thanks!
Dec 29 '05 #10

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

Similar topics

3
by: Bill Cart | last post by:
The oldDb Command does not support Named Parameters. If I am reading them correctly, the docs say that the order of the parameter should match the order they are declared in the Stored Procedure....
7
by: mp | last post by:
No value given for one or more required parameters. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information...
10
by: Adis | last post by:
Asp.Net Visual Studio 2003 SQL Server. Hi, Obtaining Data Based Upon Multiple Selections From a ListBox... I have database in Sqlserver and ListBox (Multiple Selection Mode) in my Visual...
4
by: Tim::.. | last post by:
Can someone tell me a better way or give me a link that shows a better way to create large numbers of SQL parameters... Example... A better way to write this code! <code> Sub...
11
by: Dixie | last post by:
How can I programatically, take some Date/Time fields present in a table in the current database and change their type to text? dixie
4
by: Jo Claes | last post by:
Hi, A friend asked me if i could help him building a lilttle website. Having 10 years of proffessional experiance in writing "non-webbased" code i thought that will not be that hard. I think...
4
by: gmazza | last post by:
Hi there, I am trying to insert 4 fields into a table grabbing the 4 fields from a form, here is my code: Private Sub LastPaymentAmount_AfterUpdate() Dim CurrentProject As DAO.Database Set...
0
by: AxleWacl | last post by:
Hi, The below error is what I am receiving. The code im using is below the error, for the life of me, I can not see where any parameter is missing..... Server Error in '/FleetcubeNews'...
3
by: kpeeroo | last post by:
Private Function AddCompanyOvertime() As Integer Dim companyID As Integer = GetCompanyID() Console.WriteLine(companyID) Dim paramCompanyID As New SqlParameter("@CompanyID",...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.