I have a WinForms control inherited from TreeView and I want it to automatically adjust background color according to the form (also customized) background. How to make it?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Making a control aware of its parent is normally a bad idea. There however is a dedicated method to detect the parent BackColor changing so it’s okay. BackColor is an ambient property, if it isn’t explicitly assigned then has the same value as the parent’s BackColor. So take advantage of that: