首页 > 解决方案 > 在多行文本框中具有选择或焦点的多个文本框?

问题描述

我有一个多行文本框文本框的问题,在搜索字符串时,它首先关注第一个位置的单词,但仍然通过不选择它们来继续选择其他单词 not !

这是我的代码:

If testArray(p) / 2987 >= dub + (1787 / 2987) And testArray(p) / 2987 < dub + 1 Then
                Main.TextBox31.Focus()
                Main.TextBox31.SelectionStart = Main.TextBox31.Text.IndexOf(Me.TextBox1.Text)
                Main.TextBox31.SelectionLength = Me.TextBox1.TextLength
                Main.TextBox31.ScrollToCaret()
                MsgBox("oui16")
                System.Threading.Thread.Sleep(1000)
            End If

第一行给了我搜索字节的位置。TextBox31 控件是多行控件,其中我有 testArray (p) 数组中的搜索字节。TextBox1 控件为我提供了我正在寻找的字符串。

PS:

在此处输入图像描述

标签: vb.nettextboxselection

解决方案


我能够用列表框实现这样的目标,它也可以转换为文本框吗?

                    Dim rect As Rectangle
                    Dim bruh As New SolidBrush(Color.FromArgb(120, 0, 0, 225))
                    Dim gfx As Graphics = ListBox1.CreateGraphics
                    gfx.FillRectangle(bruh, rect)

推荐阅读