【问题标题】:Predictive text in Richtextbox in vb [closed]vb中Richtextbox中的预测文本[关闭]
【发布时间】:2015-09-04 06:56:11
【问题描述】:

我几乎完成了我在 Visual basic 中的文本编辑器。我想在我的项目中添加的最后一件事是一个 sub,它会在用户每次添加时显示一个下拉菜单富文本框中的一个字母(字符)。例如,当用户在富文本框中键入 a 时,程序将显示一个下拉菜单,其中包含第一个字母为 a 的所有单词em>.. 然后如果用户在 a 之后键入 b,那么下拉菜单将包含所有前两个字母为 ab..下拉菜单将得到它来自该路径中的文本文件的话:C:/Desktop/txtfile.txt

【问题讨论】:

  • 希望和梦想非常美好。不幸的是,它们不是 SO 中的有效输入。请自己尝试一下,与我们分享并询问具体问题。

标签: vb.net richtextbox t9


【解决方案1】:

您可以使用TextBox.AutoCompleteMode Property 在文本框或富文本框中建议或附加预测文本。


(来源:net-informations.com

以下 VB.Net 程序将一些字符串值添加到 AutoCompleteStringCollection 并在输入文本时显示为自动完成文本框:

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TextBox1.AutoCompleteMode = AutoCompleteMode.Suggest
        TextBox1.AutoCompleteSource = AutoCompleteSource.CustomSource

        ' You can read the custom source file
        ' for example: File.ReadAllLine("C://Desktop//txtfile.txt")
        Dim DataCollection As New AutoCompleteStringCollection()

        addItems(DataCollection)
        TextBox1.AutoCompleteCustomSource = DataCollection
    End Sub
    Public Sub addItems(ByVal col As AutoCompleteStringCollection)            
        col.Add("Abel")
        col.Add("Bing")
        col.Add("Catherine")
        col.Add("Varghese")
        col.Add("John")
        col.Add("Kerry")
    End Sub
End Class

Reference Here

【讨论】:

  • 谢谢,这很酷!
猜你喜欢
  • 2016-04-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-06-20
  • 1970-01-01
  • 2013-02-11
相关资源
最近更新 更多