Why does my text keep highlighting?
Asked Answered
A

1

2

I am making a "toast" in vb.net, and whenever it pops up, all the text in the body textbox is ALWAYS highlighted...how can I remove the highlight programmatically?

Thanks!

Here is the code which seems to be automatically highlighting:

Dim i As Integer
        toast.HeaderL.Text = headertext
        toast.BodyL.Text = contenttext
        toast.Show()
        toast.Opacity = 0
        i = 0
        While i < 100
            toast.SetDesktopLocation(My.Computer.Screen.WorkingArea.Right - toast.Width, My.Computer.Screen.WorkingArea.Bottom - ((toast.Height / 100) * i))
            toast.Opacity += 0.01
            wait(7)
            i += 1
        End While
        wait(4000)
        toast.Opacity = 1
        i = 0
        While i < 100
            toast.SetDesktopLocation(toast.Location.X, toast.Location.Y + toast.Height / 100)
            toast.Opacity -= 0.01
            wait(7)
            i += 1
        End While
        toast.Close()

Always, the text inside BodyL (which is a textbox), highlights itself.I tried adding in toast.Focus() at some points, but that did not work.

toast is the form name.

Agreed answered 28/8, 2009 at 3:15 Comment(7)
WinForms? WPF? ASP.NET and JavaScript? We need a lot more information than you're giving us here.Nympha
Winforms, vb.net 2008, made in Visual Basic express with sp1Agreed
Can you share some code, showing what you do?Jamiejamieson
Added it. Hopefully its enough to help you answer the question lol!Agreed
What kind of control is toast?Jamiejamieson
Its a winform, with FormBorderStyle set to "none"Agreed
And BodyL is a textbox, with scrollbars set to "vertical" and which is readonly.Agreed
D
3

It's more of a guess, but you could try to add the following line, after assigning the text to BodyL:

toast.BodyL.Select(toast.BodyL.Text.Length, 0)

Another idea is to add some other control to the toast form (such as a Panel) that can receive input focus without showing (it can be made very tiny, or even have it moved outside the visible part of the form), and making sure that that control receives focus when the toast form is displayed.

Dayledaylight answered 28/8, 2009 at 19:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.