Click here to Skip to main content
15,891,567 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I create a textbox custom control.
Inside the control, I change the forecolor and backcolor.
When I use the control in a form and run it, everything seems perfect.
But when I change the custom control code, the textbox inside the form didn't change.
Is this normal?
Is there anything I can do to update the control inside the form so I don't need to delete and readd the control?

Addition :
When I change the multiline or other properties beside fore/backcolor and rebuild the project, the textbox inside my form is just like the old one.
Posted
Updated 19-Sep-13 6:32am
v2
Comments
ZurdoDev 19-Sep-13 8:36am    
No, it is not normal. Unless you compiled you control in a separate dll. Is it in the same project?
Midnight Ahri 19-Sep-13 11:26am    
Yeah I think it's working before I restored my laptop to factory setting and reinstall everything again.
Yes it is in the same project.

After changing the color, call this.Invalidate() inside the code for the text box.

In the designer things don't happen like they do when it is running. You need to force some things to happen. Calling Invalidate forces the textbox to be redrawn.
 
Share this answer
 
Comments
Midnight Ahri 19-Sep-13 12:28pm    
Where exactly I had to put this?
I tried both custom control and my form, still nothing change.
Actually it's not only color, forexample I set multiline to true.
It's still false in the form, it's like the control didn't update anymore from my custom control.
Looks like you hit a problem with the Designer and Default values. Add the DefaultValue attribute to your implementation of the property, thus the Designer will not write an entry for the property in the Form1.Designer.cs file when it has its standard value.
You can see an example at http://stackoverflow.com/questions/11929496/overriding-the-defaultvalueattribute-of-an-inherited-property[^] - but also the limitations.
 
Share this answer
 
Comments
Midnight Ahri 19-Sep-13 12:25pm    
The link is deleted.
Btw I'm pretty sure before I restore my laptop, it's still working.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900