Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Breaking change]: DateTimePicker's Text Property #41073

Closed
2 tasks done
Epica3055 opened this issue Jun 28, 2023 · 6 comments · Fixed by #41328
Closed
2 tasks done

[Breaking change]: DateTimePicker's Text Property #41073

Epica3055 opened this issue Jun 28, 2023 · 6 comments · Fixed by #41328
Assignees
Labels
breaking-change Indicates a .NET Core breaking change 🏁 Release: .NET 8 Work items for the .NET 8 release 📌 seQUESTered Identifies that an issue has been imported into Quest.

Comments

@Epica3055
Copy link
Member

Epica3055 commented Jun 28, 2023

Description

The Text property of DateTimePicker is empty before DateTimePicker's handle is created.

Version

  • .NET 8.0

Previous behavior

After DateTimePicker was constructed, Text property was available. We didn't have to wait until the handle was created.

New behavior

Text property is an empty string until the handle is created, after the handle is created, Text is set to the current date as is displayed in the control.

Type of breaking change

  • Behavioral change: Existing binaries may behave differently at run time.

Reason for change

This behavior was introduced as a fix for issue 9232, to match narrator (screen reader) announcement to the display text. Fixed by pr 9253

The reason why issue 9232 occurred is that we accessed Text by

class DateTimePicker
{
...
    public override string Text
    {
        get => Value.ToString(CustomFormat);
...
}

If we hadn't set a CustomFormat, then there would be default CustomFormat. So there would be a disparity between the Text property and the displayed text.

So we changed the logic to

class DateTimePicker
{
...
    public override string Text
    {
        get => base.Text;
...
}

base.Text is identical with native Control text. So it doesn't matter if there is CustomFormat, the Text will be consistent
with what it looks only after the handle is created.

Recommended action

Since now if the Handle is not created then the Text will be a empty string. So we recommend you to access Text in later moment like:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        Shown += DateTimePicker_Shown;
    }

    private void DateTimePicker_Shown(object sender, EventArgs e)
    {
        this.dateTimePicker1.Text;
    }
}

Feature area

Windows Forms


Associated WorkItem - 263560

@gewarren
Copy link
Contributor

@merriemcgaw
Copy link
Member

@Tanya-Solyanik will take a look and help with the breaking changes doc.

@gewarren gewarren transferred this issue from dotnet/docs Apr 2, 2024
@adegeo
Copy link
Contributor

adegeo commented May 14, 2024

@merriemcgaw what's the status of this issue?

@merriemcgaw
Copy link
Member

@Tanya-Solyanik what are your thoughts? I don't recall this issue myself.

@Tanya-Solyanik
Copy link
Member

@gewarren @merriemcgaw - we should document this as a breaking change.

@Epica3055 - please use the template mentioned above.

@Epica3055 Epica3055 changed the title DateTimePicker's Text Property [Breaking change]: DateTimePicker's Text Property May 17, 2024
@Tanya-Solyanik
Copy link
Member

@gewarren - Did we answer all questions for the breaking change?

@gewarren gewarren self-assigned this May 24, 2024
@gewarren gewarren added 🗺️ reQUEST Triggers an issue to be imported into Quest. and removed ⌚ Not Triaged Not triaged Pri3 labels May 24, 2024
@dotnet-bot dotnet-bot added the ⌚ Not Triaged Not triaged label May 24, 2024
@gewarren gewarren transferred this issue from dotnet/docs-desktop May 24, 2024
@dotnet-bot dotnet-bot removed the ⌚ Not Triaged Not triaged label May 24, 2024
@gewarren gewarren added breaking-change Indicates a .NET Core breaking change 🏁 Release: .NET 8 Work items for the .NET 8 release and removed Pri3 labels May 24, 2024
@sequestor sequestor bot added 📌 seQUESTered Identifies that an issue has been imported into Quest. and removed 🗺️ reQUEST Triggers an issue to be imported into Quest. labels Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Indicates a .NET Core breaking change 🏁 Release: .NET 8 Work items for the .NET 8 release 📌 seQUESTered Identifies that an issue has been imported into Quest.
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

6 participants