EDN Admin
Well-known member
<p style="margin:0in 0in 0pt <span style="font-family:Verdana; font-size:10pt Hello Programmers,
<p style="margin:0in 0in 0pt <span style="font-family:Verdana; font-size:10pt Iâm trying to make program to fill up several fields on a pre-printed form.
<p style="margin:0in 0in 0pt
<p style="margin:0in 0in 0pt <span style="font-family:Verdana; font-size:10pt How do I print a very long string into several lines to fill a pre-printed box on a paper?
<p style="margin:0in 0in 0pt <span style="font-family:Verdana; font-size:10pt The area on the paper is a 7.25 inches width by 2 inches height box.
<p style="margin:0in 0in 0pt
<p style="margin:0in 0in 0pt <span style="font-family:Verdana; font-size:10pt The string could be form ââ to 750 characters long.
<p style="margin:0in 0in 0pt <span style="font-family:Verdana; font-size:10pt The TextBox
<span style=" (txtDESCRIPTION) is connected to a database field. The user enters some information, no more than 750 characters which is the MaxLength property of the TextBox, later on, this information is retrieved from the database to fill the
TextBox. When the user verifies that the info in the textbox is correct, will click the Print Info button.
<p style="margin:0in 0in 0pt <span style="font-family:Verdana; font-size:10pt The following is the code Iâm using to fill up all of the boxes on the paper form, the last one (txtDESCRIPTION.text) is the one I do not know how to print because the program
has measure and split the string (without cutting the words) before it reaches the right edge of the box:<span style="font-size:10pt
<p style="margin:0in 0in 0pt <span style="font-size:10pt <span style="font-family:Times New Roman
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; color:blue; font-size:10pt private<span style="font-family:"Courier New"; font-size:10pt
<span style="color:blue void btnPrintPage1Form32_Click(<span style="color:blue object sender,
<span style="color:#2b91af EventArgs e)
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; font-size:10pt {
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; font-size:10pt <span style="
<span style=" <span style="color:blue try
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; font-size:10pt <span style="
{
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt <span style=" <span style=" printFont =
<span style="color:blue new <span style="color:#2b91af Font(<span style="color:#a31515 "Times New Roman", 10);
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; color:#2b91af; font-size:10pt <span style=" <span style=" PrintDocument<span style="font-family:"Courier New"; font-size:10pt pdocument =
<span style="color:blue new <span style="color:#2b91af PrintDocument();
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt <span style=" <span style=" pdocument.PrintPage +=
<span style="color:blue new <span style="color:#2b91af PrintPageEventHandler(<span style="color:blue this.printDocumentForm32_PrintPage);
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt <span style=" <span style=" pdocument.Print();
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; font-size:10pt <span style="
}
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; color:blue; font-size:10pt <span style="
catch<span style="font-family:"Courier New"; font-size:10pt (<span style="color:#2b91af Exception ex)
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; font-size:10pt <span style="
<span style=" {
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; font-size:10pt <span style="
<span style=" <span style="color:#2b91af MessageBox.Show(ex.Message);
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; font-size:10pt <span style="
<span style=" }
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; font-size:10pt }
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; font-size:10pt
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; color:blue; font-size:10pt private<span style="font-family:"Courier New"; font-size:10pt
<span style="color:blue void printDocumentForm32_PrintPage(<span style="color:blue object sender,
<span style="color:#2b91af PrintPageEventArgs e)
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; font-size:10pt {
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt e.Graphics.DrawString(TextBox2.Text, printFont,
<span style="color:#2b91af Brushes.Black,
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt 620, 194,
<span style="color:blue new <span style="color:#2b91af StringFormat());
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt e.Graphics.DrawString(TextBox3.Text, printFont,
<span style="color:#2b91af Brushes.Black,
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt 620, 209,
<span style="color:blue new <span style="color:#2b91af StringFormat());
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt e.Graphics.DrawString(TextBox4.Text, printFont,
<span style="color:#2b91af Brushes.Black,
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt 33, 218,
<span style="color:blue new <span style="color:#2b91af StringFormat());
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt e.Graphics.DrawString(TextBox5.Text, printFont,
<span style="color:#2b91af Brushes.Black,
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt 33, 242,
<span style="color:blue new <span style="color:#2b91af StringFormat());
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt e.Graphics.DrawString(TextBox6.Text, printFont,
<span style="color:#2b91af Brushes.Black,
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt 395, 242,
<span style="color:blue new <span style="color:#2b91af StringFormat());
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt e.Graphics.DrawString(TexBox7.Text, printFont,
<span style="color:#2b91af Brushes.Black,
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt 630, 242,
<span style="color:blue new <span style="color:#2b91af StringFormat());
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt e.Graphics.DrawString(TextBox8.Text, printFont,
<span style="color:#2b91af Brushes.Black,
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt 700, 242,
<span style="color:blue new <span style="color:#2b91af StringFormat());
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt e.Graphics.DrawString(TextBox9.Text, printFont,
<span style="color:#2b91af Brushes.Black,
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt 760, 242,
<span style="color:blue new <span style="color:#2b91af StringFormat());
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt e.Graphics.DrawString(txtDESCRIPTION.Text.ToString(), printFont,
<span style="color:#2b91af Brushes.Black,
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt 33, 280,
<span style="color:blue new <span style="color:#2b91af StringFormat());
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; font-size:10pt }
<p style="margin:0in 0in 0pt <span style="font-family:Verdana; font-size:10pt
<p style="margin:0in 0in 0pt <span style="font-family:Verdana; font-size:10pt
<p style="margin:0in 0in 0pt <span style="font-family:Verdana; font-size:10pt Thank you in advance for your help. <hr class="sig Learning computer programming with c#
View the full article
<p style="margin:0in 0in 0pt <span style="font-family:Verdana; font-size:10pt Iâm trying to make program to fill up several fields on a pre-printed form.
<p style="margin:0in 0in 0pt
<p style="margin:0in 0in 0pt <span style="font-family:Verdana; font-size:10pt How do I print a very long string into several lines to fill a pre-printed box on a paper?
<p style="margin:0in 0in 0pt <span style="font-family:Verdana; font-size:10pt The area on the paper is a 7.25 inches width by 2 inches height box.
<p style="margin:0in 0in 0pt
<p style="margin:0in 0in 0pt <span style="font-family:Verdana; font-size:10pt The string could be form ââ to 750 characters long.
<p style="margin:0in 0in 0pt <span style="font-family:Verdana; font-size:10pt The TextBox
<span style=" (txtDESCRIPTION) is connected to a database field. The user enters some information, no more than 750 characters which is the MaxLength property of the TextBox, later on, this information is retrieved from the database to fill the
TextBox. When the user verifies that the info in the textbox is correct, will click the Print Info button.
<p style="margin:0in 0in 0pt <span style="font-family:Verdana; font-size:10pt The following is the code Iâm using to fill up all of the boxes on the paper form, the last one (txtDESCRIPTION.text) is the one I do not know how to print because the program
has measure and split the string (without cutting the words) before it reaches the right edge of the box:<span style="font-size:10pt
<p style="margin:0in 0in 0pt <span style="font-size:10pt <span style="font-family:Times New Roman
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; color:blue; font-size:10pt private<span style="font-family:"Courier New"; font-size:10pt
<span style="color:blue void btnPrintPage1Form32_Click(<span style="color:blue object sender,
<span style="color:#2b91af EventArgs e)
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; font-size:10pt {
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; font-size:10pt <span style="
<span style=" <span style="color:blue try
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; font-size:10pt <span style="
{
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt <span style=" <span style=" printFont =
<span style="color:blue new <span style="color:#2b91af Font(<span style="color:#a31515 "Times New Roman", 10);
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; color:#2b91af; font-size:10pt <span style=" <span style=" PrintDocument<span style="font-family:"Courier New"; font-size:10pt pdocument =
<span style="color:blue new <span style="color:#2b91af PrintDocument();
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt <span style=" <span style=" pdocument.PrintPage +=
<span style="color:blue new <span style="color:#2b91af PrintPageEventHandler(<span style="color:blue this.printDocumentForm32_PrintPage);
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt <span style=" <span style=" pdocument.Print();
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; font-size:10pt <span style="
}
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; color:blue; font-size:10pt <span style="
catch<span style="font-family:"Courier New"; font-size:10pt (<span style="color:#2b91af Exception ex)
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; font-size:10pt <span style="
<span style=" {
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; font-size:10pt <span style="
<span style=" <span style="color:#2b91af MessageBox.Show(ex.Message);
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; font-size:10pt <span style="
<span style=" }
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; font-size:10pt }
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; font-size:10pt
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; color:blue; font-size:10pt private<span style="font-family:"Courier New"; font-size:10pt
<span style="color:blue void printDocumentForm32_PrintPage(<span style="color:blue object sender,
<span style="color:#2b91af PrintPageEventArgs e)
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; font-size:10pt {
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt e.Graphics.DrawString(TextBox2.Text, printFont,
<span style="color:#2b91af Brushes.Black,
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt 620, 194,
<span style="color:blue new <span style="color:#2b91af StringFormat());
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt e.Graphics.DrawString(TextBox3.Text, printFont,
<span style="color:#2b91af Brushes.Black,
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt 620, 209,
<span style="color:blue new <span style="color:#2b91af StringFormat());
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt e.Graphics.DrawString(TextBox4.Text, printFont,
<span style="color:#2b91af Brushes.Black,
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt 33, 218,
<span style="color:blue new <span style="color:#2b91af StringFormat());
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt e.Graphics.DrawString(TextBox5.Text, printFont,
<span style="color:#2b91af Brushes.Black,
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt 33, 242,
<span style="color:blue new <span style="color:#2b91af StringFormat());
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt e.Graphics.DrawString(TextBox6.Text, printFont,
<span style="color:#2b91af Brushes.Black,
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt 395, 242,
<span style="color:blue new <span style="color:#2b91af StringFormat());
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt e.Graphics.DrawString(TexBox7.Text, printFont,
<span style="color:#2b91af Brushes.Black,
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt 630, 242,
<span style="color:blue new <span style="color:#2b91af StringFormat());
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt e.Graphics.DrawString(TextBox8.Text, printFont,
<span style="color:#2b91af Brushes.Black,
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt 700, 242,
<span style="color:blue new <span style="color:#2b91af StringFormat());
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt e.Graphics.DrawString(TextBox9.Text, printFont,
<span style="color:#2b91af Brushes.Black,
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt 760, 242,
<span style="color:blue new <span style="color:#2b91af StringFormat());
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt e.Graphics.DrawString(txtDESCRIPTION.Text.ToString(), printFont,
<span style="color:#2b91af Brushes.Black,
<p style="margin:0in 0in 0pt 0.5in <span style="font-family:"Courier New"; font-size:10pt 33, 280,
<span style="color:blue new <span style="color:#2b91af StringFormat());
<p style="margin:0in 0in 0pt <span style="font-family:"Courier New"; font-size:10pt }
<p style="margin:0in 0in 0pt <span style="font-family:Verdana; font-size:10pt
<p style="margin:0in 0in 0pt <span style="font-family:Verdana; font-size:10pt
<p style="margin:0in 0in 0pt <span style="font-family:Verdana; font-size:10pt Thank you in advance for your help. <hr class="sig Learning computer programming with c#
View the full article