When I scroll through the text of my rich text box, it doest scroll fast and smoothly. It works perfectly fine for files of size up to 1 MB, but it gets very slow if I use file in the range of 10MB. The richtextbox I am using is on the form named subform. I am doing subform.TopLevel = false
and putting inside a panel on Mainform. From Mainform using object of Subform I am calling subform.richtextbox.Loadfile(filepath)
.
If I directly run the Subform and load file like this.richtextbox.Loadfile(filepath)
, the scrolling is working perfectly fine for same file.
Please note , the loading of file itself takes much time, which is not a concern for me right now. I will look into that, once I solve this issue. I want my scroll and all UI operation to work like it works in Notepad and Notepad++ without freezing.
I have pasted the final UI, that I have created
// Subform Code
public SubForm(Form form)
{
mainform = form as MainForm;
InitializeComponent();
public MyRichTextBox richtextbox;
}
// MainForm code
public partial class MainForm : Form
{
private void MainForm_Load(object sender, EventArgs e)
{
dumpsysform = new SubForm(this);
dumpsysform.TopLevel = false;
dumpsysform.Text = "DumpsysLog";
kernelform = new SubForm(this);
kernelform.TopLevel = false;
kernelform.Text = "KernelLog";
this.panel3.Controls.Add(adbform);
this.panel3.Controls.Add(dumpsysform);
this.panel3.Controls.Add(kernelform);
dumpsysform.Location = new Point(0, panel3.Height / 3);
kernelform.Location = new Point(0,2* panel3.Height / 3);
adbform.Show();
dumpsysform.Show();
kernelform.Show();
}
// Button to open file and read
private void btn_click(object sender, EventArgs e)
{
dumpsysform.richtextbox.richtextbox1.LoadFile(dumpsysfilepath,
RichTextBoxStreamType.PlainText);
kernelform.richtextbox.richtextbox1.LoadFile(kernelfilepath,
RichTextBoxStreamType.PlainText);
}
}