change parameters of all text

  • Thread starter Thread starter matt
  • Start date Start date
M

matt

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?
 
matt said:
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
 
Chris said:
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!
 
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


Chris said:
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!
 
Siva M said:
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,
 
Shiva
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
 
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

Siva M said:
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,
 
Cor Ligthert said:
Shiva
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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top