Link to home
Start Free TrialLog in
Avatar of kingjamez
kingjamez

asked on

Parsing a RichText Box like a file?

I am trying to parse email. I have created a richtext box that allows me to drag and drop an email file over it and the email appears in the RichText Box. I want to be able to step through that RichText Box line by line and parse it. Can I use similar commands for stepping through a file to step through the RichText Box? Here is the code that I used to drag and drop the email file into the RichText Box.

private void Form1_Load(object sender, System.EventArgs e)
{          
this.richTextBox1.DragEnter += new System.Windows.Forms.DragEventHandler(this.richTextBox1_DragEnter);  
this.richTextBox1.DragDrop += new System.Windows.Forms.DragEventHandler(this.richTextBox1_DragEnter);  
this.richTextBox1.AllowDrop = true;
}

private void richTextBox1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)  
{  
if (((DragEventArgs)e).Data.GetDataPresent(DataFormats.Text))  
     ((DragEventArgs)e).Effect = DragDropEffects.Copy;
 
else  
     ((DragEventArgs)e).Effect = DragDropEffects.None;  
}
 
private void richTextBox1_DragDrop(object sender, DragEventArgs e)  
{  
richTextBox1.LoadFile((String)e.Data.GetData("Text"), System.Windows.Forms.RichTextBoxStreamType.RichText);  
}

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of smitty22
smitty22

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial