private void btnStart_Click(object sender, EventArgs e) { var shaps = new List<Shape> { new Rectangle(), new Triangle(), new Cicrle() }; foreach (Shape s in shaps) { rtxtDisplay.SelectionStart = rtxtDisplay.Text.Length; if (s.Draw().Contains("圆")) { rtxtDisplay.SelectionColor = Color.Red; } else if (s.Draw().Contains("矩形")) { rtxtDisplay.SelectionColor = Color.Green; } else { rtxtDisplay.SelectionColor = Color.Yellow; } rtxtDisplay.AppendText(s.Draw()); rtxtDisplay.AppendText(System.Environment.NewLine); } rtxtDisplay.AppendText(System.Environment.NewLine); }
标签:Draw,每行,颜色,Color,RichTextBox,SelectionColor,new,rtxtDisplay,AppendText From: https://www.cnblogs.com/wenjie0904/p/18350514