1
Answer

Problem with the scrollbar which is attached to a textbox

Ask a question
kandy

kandy

17y
6.5k
1

Hi All,

I am facing problem with the text box whose scrollbars property is enabled to "both".

The Problem is when i retrieve data from a file and show its content in the textbox above specified, I allow the user to type and I have written a small module which when user types "enter"  key  the format(that is number of tabs or spaces) present in the previous line will be applied to the new line created.

To say it in simple words  it is little like the c# programming environment regarding the paragraph indentations it provides to us when we type enter key.

Since I wanted to add text in the textbox in any place where user wish, i am retrieving the text and doing my operations and i put the updated  one back to the textbox.

In the above case when data is too large so the scrollbar is active,since i am adding the text in the textbox, the scrollbar is showing the  first position though the cursor is blinking in the nextpage.

when I attempt to write it scrollbar moves and it is showing the place where cursor is moving,the moment i type enter it is doing the same i told above. so it is giving a flickering effect. It is annoying a lot.

I had used richtextbox and all those suspendlayout and resumelayout.

Here is my code

\\ code

richTextBox1.SuspendLayout();

     \\      gets the current position

iPosition = richTextBox1.SelectionStart;

\\        finds the format of the previous line and stores that in formatpattern string

FormatPattern = FindFormatPattern(richTextBox1.Text, iPosition - 2);

\\        here am adding it in the textbox

richTextBox1.Text = richTextBox1.Text.Insert(iPosition,FormatPattern);

\\ setting the current position

 

richTextBox1.Select(iPosition + FormatPattern.Length, 0);

richTextBox1.ResumeLayout(true);

\\      code ends

 

Thanks In Advance

kandy

 


Answers (1)