Flickering TextBox (Urgent)

G

Guest

Hello,

Someone Please help me.... I need to fix this urgently, and cant find a solution anywhere.

I've developed an application in VB. NET where the text in a textbox is either frequently appended or altered. Now everytime text is added to the textbox the cursor goes to the beggining of the screen and then comes back down which makes the textbox flicker. Since the textbox is a multiline textbox the problem becomes more visible when the scrollbars are visible.

What can I do to fix this problem.

This is my first app so some coding to explain the resolution of the problem will be much appreciated.

Thanks

Vishal
 
O

omnimicro

Vishal,
Any chance you could post some of the code? Its difficult to tell from your
message what events are causing the cursor movement.
 
G

Guest

Hi There,

My Code is as follows:


Dim selectLength As Integer = Message.SelectionLength
Dim beforeText As String = Message.Text
Dim selectStartPosition As Integer = Message.SelectionStart
Dim leftOfSelection as string = Microsoft.VisualBasic.Left(beforeText, Message.SelectionStart)
Dim rightofselection as string = Mid(beforeText, selectStartPosition + selectLength + 1)
Dim newString As String = leftOfSelection + textToAdd + rightofselection
Message.Text = newString

If textToAdd = "" Then
Message.SelectionStart = selectStartPosition
Else
Message.SelectionStart = selectStartPosition + 1
End If

Message.SelectionLength = 0 'Nothing selected now

Message.ScrollToCaret()

Regards
Vishal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top