private void textBoxSource_TextChanged(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBoxSource.Text)) { textBoxDestination.Text = ""; } try { XmlDocument newDocument = new XmlDocument(); newDocument.LoadXml(textBoxSource.Text); string Destination = XmlOperation.Beautify(newDocument); textBoxDestination.Text = Destination; textBoxSource.ForeColor = Color.Black; } catch { textBoxSource.ForeColor = Color.Red; } }