Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello every one i need to draw checkbox at print document there is any Idea??
thankyou...

What I have tried:

Graphics gg;

try
{
gg.DrawString(chk_acc.Text, chk_acc.Font, new SolidBrush(chk_acc.ForeColor), chk_acc.Right - chk_acc.Height - gg.MeasureString(chk_acc.Text, chk_acc.Font).Width, chk_acc.Top, new StringFormat());
ControlPaint.DrawCheckBox(gg, 250, 250, 25, 25, ButtonState.Checked);

}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
Posted
Updated 10-Jan-18 0:55am
Comments
[no name] 8-Jan-18 4:49am    
Are you serious that you need to draw a checkbox or append/prepend a checkbox to a document while you print for it from your application?
Maciej Los 8-Jan-18 16:06pm    
There's a workaround of it...
Use Wingdings font and pass Unicode character: U+1F5F9. See: Wingdings character set and equivalent Unicode characters[^]

1 solution

try to use utf-8 special characters and draw it with your text..
C#
string boxChecked = "☑"; // utf-8 special character
               string boxnonChecked = "☐";
               FontFamily family = new FontFamily("Microsoft Sans Serif");//change the text size by font size
               Font font = new System.Drawing.Font(family, 9, FontStyle.Bold);//ch
               Point DrawLocation = new Point(5, 5); // point of text location
               string DrawText = "the text you want to draw it..";
               gg.DrawString(DrawText, font, new SolidBrush(Color.Red), DrawLocation);


and if you want smooth text give try to GraphicsPath , and update this Graphics Properties
C#
gg.InterpolationMode = InterpolationMode.HighQualityBicubic;
gg.CompositingQuality = CompositingQuality.HighQuality;
gg.PixelOffsetMode = PixelOffsetMode.HighQuality;
gg.SmoothingMode = SmoothingMode.HighQuality;
using (GraphicsPath gp = new GraphicsPath())
   {
          string boxChecked = "☑"; // utf-8 special character
          string boxnonChecked = "☐";
          FontFamily family = new FontFamily("Microsoft Sans Serif");//change the text size by font size
          Font font = new System.Drawing.Font(family, 9, FontStyle.Bold);//ch
          Point DrawLocation = new Point(5, 5); // point of text location
          string DrawText = "the text you want to draw it..";
          gp.AddString(DrawText, font.FontFamily,(int)font.Style,font.Size,DrawLocation, StringFormat.GenericDefault);
   }
gg.DrawPath(penDefault, gp);

good luck.
 
Share this answer
 

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