private void button1_Click(object sender, EventArgs e) { string str = this.textBox1.Text.Trim(); char[] chars = str.ToCharArray(); if (chars.Length > 0) { for (int i = 0; i < chars.Length; i++) { for (int j = 0; j < chars.Length - 1; j++) { char temp = chars[j]; if (chars[j] > chars[j + 1]) { chars[j] = chars[j + 1]; chars[j + 1] = temp; } } } } foreach (char c in chars) this.m_printText += c; PrintDialog dialog = new PrintDialog(); PrintDocument doc = new PrintDocument(); doc.PrintPage+=new PrintPageEventHandler(doc_PrintPage); dialog.AllowPrintToFile = true; dialog.Document = doc; if (dialog.ShowDialog() == DialogResult.OK) doc.Print(); } protected void doc_PrintPage(Object sender, PrintPageEventArgs e) { Graphics g = e.Graphics; g.DrawString(this.m_printText,new System.Drawing.Font ("Arial",10,FontStyle.Regular),Brushes.Black,new System.Drawing.PointF(20,20)); e.HasMorePages = false; }
Never give up! Smile to the world! http://excelcsharp.blog.com/
Login to post response