【问题标题】:.NET ComboBox Autocomplete failing on slashes.NET ComboBox 自动完成在斜杠上失败
【发布时间】:2010-10-15 16:57:20
【问题描述】:

.NET ComboBox 自动完成不会完全自动完成,显示文本包含斜线。它只完成到斜线,留下 SelectedIndex == -1 和 SelectedValue == null。

无论您的 autocompletesource 是否设置为 ListItems 而不是 FileSystem 或 URL,这种行为都会愚蠢地持续存在。

是否有任何解决方法不涉及仅丢弃 ComboBox 类并编写“MyComboBox”类?

【问题讨论】:

    标签: .net combobox autocomplete


    【解决方案1】:

    我能找到的最简单的解决方案是从syncfusion.com 下载syncfusion 的免费社区winforms 控件包并使用他们的sfCombobox。他们的自动完成功能正常工作。微软应该真正解决这个问题,虽然它很痛苦。

    【讨论】:

      【解决方案2】:

      @hal9000 我也在寻找修复方法,我在 msdn 网站上找到了 Paul Cull 的一段代码:

      Private Sub cbCode_Validating(sender As Object, e As 
      System.ComponentModel.CancelEventArgs) Handles cbCode.Validating
         
      Dim s As String
         
      If cbCode.SelectedIndex = -1 And cbCode.Text <> "" Then
      ' Let's see if it ends with a slash
       s = cbCode.Text
       If s.EndsWith("\") Or s.EndsWith("/") Then cbCode.SelectedIndex = cbCode.FindString(s)
      End If
      
      End Sub
      

      【讨论】:

        【解决方案3】:

        看起来 MS 很清楚这种行为。我怀疑你已经在他们的文档页面上看到了注释,如果没有的话,链接是 here

        【讨论】:

        • 是的,我已经看到了。但我在那个页面上没有找到解决方案。
        • 那时你可能也见过这个“解决方案”:social.msdn.microsoft.com/Forums/en-US/winforms/thread/…
        • 你有没有找到解决方案?我知道这个评论已经晚了十年,但他们似乎仍然没有解决办法
        猜你喜欢
        • 2015-06-10
        • 2023-02-03
        • 2011-10-06
        • 2017-08-23
        • 1970-01-01
        • 2011-04-07
        • 2021-12-31
        • 1970-01-01
        • 2017-11-30
        相关资源
        最近更新 更多