I need to add attributes to certain controls in a Windows Forms project. It needs to look something like this:
C#
[Queryable()] private System.Windows.Forms.TextBox txtName;
[Queryable()] private System.Windows.Forms.DateTimePicker dtpDateOfBirth;
VB.NET
<Queryable()> Private WithEvents txtName As System.Windows.Forms.TextBox
<Queryable()> Private WithEvents dtpDateOfBirth As System.Windows.Forms.DateTimePicker
I can go in and edit the designer file to get more-or-less the desired effect, but those designer files sometimes come with the caveat that they are automatically-generated files. I’m worried that the designer might overwrite any changes that I make to the file. That said, is there a way to add attributes to controls using the designer or is there some way that I can add the attributes in a separate file?
You could test it, but I don’t think the definition will get overwritten when using the forms designer. Only if you delete and re-add the control. Possibly if you copy a control the copy might not have the attribute on it. I have had to change controls from
privatetoprotectedand that worked. I would think attributes would be the same.