Force UI of control to refresh on certain control property changed -
11-16-2007
, 05:40 AM
How do i make my custom control repaint certain component on control when
another property is changed?
Consider this example.
When i add windows label on form it's text value is automatically set to
label1.
Then i open proerties tab and change Text property and when i hit enter this
new value imediately get's reflected on label
.... i mean i set text to "label2" hit enter and imediately results are there
.... on the control so something causes control to be repainted...
Now ... another example let's say i add some property to default label
called TextEnding which should add some kind of additional text to
label.Text property.
No idea why this would be useful in any scenario, but let's just consider i
want this to be done.
So i would write something like this
[DesignerSerializationVisibility(DesignerSerializat ionVisibility.Visible)]
[Bindable(false)]
[DefaultValue("")]
[Category("Appearance")]
[RefreshProperties(RefreshProperties.All)]
public string TextEnding
{
get
{
return textEnding;
}
set
{
textEnding = value;
Text = Text + value;
}
}
So if i now, if i open properties tab and set " the end" to TextEnding
property i would imediatelly see the changes on Text property
and it would look like this "label1 the end", BUT these changes would not
appear on label ... label control would still have its default value label1
only after build the new value get's reflected visually. The question is
what attributes should i apply to get the value changed imediatelly ? |