Closed paul1956 closed 7 months ago
@Olina-Zhang do you know if there is a related designer issue?
@Olina-Zhang do you know if there is a related designer issue?
Similar internal designer issue: https://github.com/microsoft/winforms-designer/issues/4261 (closed as no planning to address this in the foreseeable future), which is from VS feedback, customer has some suggestion for "Warning" Properties Window with Suggested that only one OK-Button, because the extra Cancel-button is useless, or (better): the OK-Button resets the name to the former valid value and the Cancel-Button will be renamed to Retry and keeps the invalid value.
It doesn't look like this will be something we can get our schedule in the near future, but this does count as a second request for this feature. I'm going to go ahead and close this issue as well, but someone can still comment on the feedback ticket. Please go ahead and add your comment there and we will continue to keep track of it in case other votes start coming in.
Background and motivation
When using WinForms Designer UI to create controls especially DataGridViewColumns (where error has bigger impact), invalid characters should not be allowed in the Name field, especially spaces or names that exceed the maximum number of characters allowed this is most important for paste.
Roslyn has functions to validate characters in name and Max length by language, and they or something similar is already being used to validate the Name. Manual entry or paste should do something because otherwise the error does not happen until you try to leave the field or save.
If you are not going to stop the error from happening by only allowing valid characters, there are 2 options for the error dialog (OK or Cancel), and both do exactly the same thing and why do I need to click on details to see it, that information should just appear telling exactly what character(s) is invalid.
Specifically, for DataGridViewColumns the Name and Header Text are Typically the same with possibly some information before or after, for example: Header Name = "Record Number" Column Name might be ColumnRecordNumber or RecordNumber or RecordNumberColumn, I would just be able to paste "Record Number" before, after or over the default Name. with or without the " and with the space.
API Proposal
N/A
API Usage
N/A
Alternative Designs
Improve error to explain what is wrong.
Risks
Minimal, Roslyn also has all this code and you can just call it for key validation or Paste.
Will this feature affect UI controls?
This is a designer feature request to improve naming of controls. It might help accessibility, if invalid characters are not allowed. No it should be invisible to UI assuming invalid characters are just ignored.