Skip to content

Ctrl+Backspace modifies readonly TextBox when AutoCompleteMode and AutoCompleteSource are not None #13276

@Kratohs

Description

@Kratohs

.NET version

net9.0-windows

Did it work in .NET Framework?

Not tested/verified

Issue description

Pressing Ctrl+Backspace in a TextBox that has no selection and has ReadOnly set to true modifies its text as if it were not read-only if AutoCompleteMode and AutoCompleteSource are not None.

Attached is a minimal reproduction. In a more realistic scenario, ReadOnly might be set to true in response to an event, some time after it was initialized as false.

Steps to reproduce

Bug.fsproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net9.0-windows</TargetFramework>
    <UseWindowsForms>true</UseWindowsForms>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="Program.fs" />
  </ItemGroup>

</Project>

Program.fs

open System
open System.Windows.Forms

[<EntryPoint; STAThread>]
let main _ =
    let tb =
        new TextBox
            ( AutoCompleteMode = AutoCompleteMode.SuggestAppend
            , AutoCompleteSource = AutoCompleteSource.CustomSource
            , Text = "abc"
            , ReadOnly = true
            )
    let f = new Form()
    f.Controls.Add tb
    f.ShowDialog() |> ignore
    0

dotnet run

Ctrl+Backspace deletes text if there is no selection.

Metadata

Metadata

Assignees

Labels

external-OS-issueIssue caused by an external OS component such as Common Controls.investigateItems we want to investigate before making a decision on an issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions