It seems that the error always occurs on a line that consists of my main richtextbox control, and occasionally visual studio creates a listing for it in its autos, section that says there was an accessviolation to the rich text box control. anyhow here is the code.
private void linesAlphabeticallyToolStripMenuItem_Click(object sender, EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
statusBarText.Text = "Sorting Alphabetically, Please be Patient.";
// ProgressBar.Visible = true;
statusBar.Refresh();
// ProgressBar.Value = 0;
// ProgressBar.Maximum = getLineCount(txtMain.Text, false) * 2;
myundo.CheckPoint(txtMain.Text);
// List<String> myalphalines = txtMain.Text.Split('\n').ToList();
// myalphalines.Sort();
// txtMain.Text = String.Join("\n", myalphalines.ToArray());
List<string> myLines = new List<string>();
using (StringReader r2 = new StringReader(txtMain.Text))
{
string txtLine;
while ((txtLine = r2.ReadLine()) != null)
{
myLines.Add(txtLine);
// ProgressBar.Value += 1;
}
}
myLines.Sort();
using (StringWriter sw = new StringWriter())
{
foreach (string s in myLines)
{
sw.WriteLine(s);
// ProgressBar.Value += 1;
}
txtMain.Text = sw.ToString();
txtMain.Modified = true;
// ProgressBar.Visible = false;
statusBarText.Text = "";
}
myLines = null;
if (Settings.Default.showLineCount == true)
this.currentLineCountSSL.Text = getLineCount(txtMain, false).ToString();
Cursor.Current = Cursors.Default;
}
private void linesAlphToolStripMenuItem_Click(object sender, EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
myundo.CheckPoint(txtMain.Text);
statusBarText.Text = "Sorting Alphanumerically, Please be Patient.";
// ProgressBar.Visible = true;
statusBar.Refresh();
// ProgressBar.Value = 0;
// ProgressBar.Maximum = getLineCount(txtMain.Text, false) * 2;
List<string> myANLines = new List<string>();
NumericComparer ns = new NumericComparer();
using (StringReader rAn = new StringReader(txtMain.Text))
{
string txtLine;
while ((txtLine = rAn.ReadLine()) != null)
{
myANLines.Add(txtLine);
// ProgressBar.Value += 1;
}
}
string[] sortArray = myANLines.ToArray();
myANLines = null;
// string[] sortArray = txtMain.Text.Split('\n').ToArray(); …