Hi Mauricio,
Thanks for your reply!
My understanding to your problem now is,
You now have a label on your MDI form, you didn't set the Label.ForeColor
explicitly, then you modified the value of Form.ForeColor property and
found the the text color of label was changed
with the Form.ForeColor.
If my understanding is correct, this should be a correct behavior.
Control.ForeColor (also Control.BackColor, Control.Font) are marked as
Ambient property (using AmbientValueAttribute), Ambient properties query
their parent for their value, in your case, if Label.ForeColor is not set
explicitly, label.ForeColor will query the ForeColor of MDI form. Using
Ambient value, it'll make easier to design UI in with consistent look.
Basically, if you set an Ambient property explicitly to a value other than
it's Ambient Value (the value specified in the AmbientValueAttribute). the
Ambient property should work as a normal property, that is , it will not
changed according to the value of the parent value.
You may verify this in the following steps:
1. create a new form and pub some labels on it.
2. set label1.ForeColor to "Red" in the properties pane, you should see the
textcolor of label1
changed to red.
3. now set Form.ForeColor to "Green", you should see the textcolor of rest
labels changed to green, however label1 remained unchanged.
Here is a snippet for run-time
<code>
Form2 f = new Form2();
f.MdiParent = this;
//set label1 to public
f.label1.ForeColor = Color.Red;
f.ForeColor = Color.Green;
f.Show();
</code>
Does this answer your question?
If you have anything unclear on this issue, please feel free to reply this
thread.
Thanks!
Best regards,
Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, "online" should be removed before
sending.