Click here to Skip to main content
14,767,617 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am wondering how one would make it so that when I use MultiLine textBox it will recognize that there is multiple lines!

Here is how I am opening them with Open File Dialog:

OpenFileDialog ofd2 = new OpenFileDialog();
            if (ofd2.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                XmlSerializer xs = new XmlSerializer(typeof(Information));
                FileStream read = new FileStream(ofd2.FileName, FileMode.Open, FileAccess.Read, FileShare.Read);
                Information info = (Information)xs.Deserialize(read);

                textBox1.Text = info.Notes;
            }
        }


This is how I am saving them for the time being:

SaveFileDialog sfd = new SaveFileDialog();
sfd.Title = "Save File";
if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
    try
    {
        Information info = new Information();
        info.Notes= textBox1.Text;
        SaveXML.SaveData(info, sfd.FileName + ".xml");
    }
    catch(Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}


Hopefully someone can help me do this a better way or explain to me how I can get the opening part of the script to recognize that their are enters in the script...

I have been looking at other programs I use made from C# that others have written and one thing I noticed is when you save on one of the programs it would make you multiline textbox have a ";" after time you hit enter and somehow it would rexognize this on opening of the program, maybe we could figure out how to do this?

Thanks, GOOBER.
Posted
Comments
_Asif_ 26-May-14 7:56am
   
I am sorry but i couldnt understand. Can you please be more specific and give example!
Kornfeld Eliyahu Peter 26-May-14 8:01am
   
What between xml and lines? Use some xml parser class (http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx) to deal with...
gggustafson 26-May-14 13:02pm
   
May I suggest that you use a RichTextBox rather than a multi-line TextBox. Have you considered revising your algorithm to use XmlWriter, XmlWriterSettings, and StringBuilder? The XmlWriterSettings can make your XML human readable.
xG00BERx 26-May-14 23:23pm
   
This Fixed it! Thank you so much, all I really had to do is change the textBox into a RichTextBox and my application and xml read it just fine, I will continue to learn and understand XML with the other ideas that you have all give me! Thank you!!!!!!

Btw? How do I go about marking this answer as a Solution? Sorry new around here xD
gggustafson 27-May-14 9:06am
   
This was a reply/question, so it is not a solution. I would need to move my reply to the solution area below. That causes the question to drop off the Unanswered questions list. Also, from what I understand you can then rate and mark a solution as "the solution". I'll move my reply to the Solutions.
xG00BERx 27-May-14 12:40pm
   
Once again thank you so much for your time and your help, hope to see you around!

1 solution

May I suggest that you use a RichTextBox rather than a multi-line TextBox. Have you considered revising your algorithm to use XmlWriter, XmlWriterSettings, and StringBuilder? The XmlWriterSettings can make your XML human readable.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900