IgnaceMaes / MaterialSkin

Theming .NET WinForms, C# or VB.Net, to Google's Material Design Principles.
MIT License
2.84k stars 831 forks source link

[SingleLineTextFields] sender != the Textfield itself? #138

Open Zeziroth opened 7 years ago

Zeziroth commented 7 years ago

Hello, today i found a curious "bug", i think.

I wanted to make some Placeholders in my Textfields, so i crashed into my first Problem. Changing the ForeColor in the FormDesigner will NOT affect the Runtime appereance of the Textfield.

Then i thought, huhm... okay lets set the ForeColor at the Formstart... Did that -> But nothing happened....

After that i written the Placeholder Code first: [code] Private Sub MaterialSingleLineTextField2_LostFocus(sender As Object, e As EventArgs) Handles MaterialSingleLineTextField2.LostFocus If sender.text = "" Then sender.text = "XXX" sender.ForeColor = Color.DarkGray End If End Sub [/code] Nothing special ^^ So THAT will affect the REAL Textfield ForeColor...

The Reference of sender is not the same as the Reference of MaterialSingleLineTextField2, wtf? ^^

Need help, i want to change the visible ForeColor at Startup, and not after they Focused/Unfocused it :/

greatPHPer commented 3 years ago

I solved this issue

(((sender as Control).Parent) as MaterialSkin.Controls.MaterialSingleLineTextField).Text=""
(((sender as Control).Parent) as MaterialSkin.Controls.MaterialSingleLineTextField).ForeColor=Color.DrakGray