MDI Trouble

  • Thread starter Thread starter Mauricio
  • Start date Start date
M

Mauricio

My project has a mdi form and a mdi child.
In the child form there is a label object with forecolor
propety set black.
When the child form is showed its label object is not
black, it´s gray like disabled. Why?

Thanks.
 
* "Mauricio said:
My project has a mdi form and a mdi child.
In the child form there is a label object with forecolor
propety set black.
When the child form is showed its label object is not
black, it´s gray like disabled. Why?

Does this occur with any label placed on the child? Does that even
occur in a blank project?
 
Hi Mauricio,

Since this problem could not be reproed from a simple blank project, I
don't know where the problem is, More detail information is needed to
further investigating this issue, could you let us know more about your
project, especially what you have done on the MDI child window? Also,
sometimes 3rd party components also affect, if your project uses any 3rd
party components, you may try creating a new MDI form without these
components.

If the problem still exists, If it possible , it will be helpful if you
could sepearate this problem into a small repro sample and let me take a
look at it.
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.
 
I discovered that the Labels ForeColor property of the
child form get the same color of the MDI ForeColor
property. Is this corret?
This also occur in a blank solution.
 
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.
 
Back
Top