printdocument中的Drawcheckbox C# [英] Drawcheckbox in printdocument C#
问题描述
你好每个我需要在打印文件上绘制复选框有什么想法??
谢谢你...
我尝试过:
图形gg;
尝试
{
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(例外情况)
{
MessageBox.Show(ex.Message);
}
尝试使用utf-8特殊字符并用你的文字绘制..
< pre lang =c#> string boxChecked = ☑; // utf-8特殊字符
string boxnonChecked = ☐;
FontFamily family = new FontFamily( Microsoft Sans Serif); // 按字体大小更改文字大小
Font font = new System.Drawing.Font(family, 9 ,FontStyle.Bold); // ch
Point DrawLocation = new Point( 5 , 5 ); // 文本位置点
string DrawText = 要绘制它的文本..;
gg.DrawString(DrawText,font, new SolidBrush(Color.Red),DrawLocation);
如果你想要流畅的文字,请尝试 GraphicsPath ,并更新此图形属性
gg .InterpolationMode = InterpolationMode.HighQualityBicubic;
gg.CompositingQuality = CompositingQuality.HighQuality;
gg.PixelOffsetMode = PixelOffsetMode.HighQuality;
gg.SmoothingMode = SmoothingMode.HighQuality;
使用(GraphicsPath gp = new GraphicsPath())
{
string boxChecked = ☑; // utf-8特殊字符
string boxnonChecked = ☐;
FontFamily family = new FontFamily( Microsoft Sans Serif); // 按字体大小更改文字大小
Font font = new System.Drawing.Font(family, 9 ,FontStyle.Bold); // ch
Point DrawLocation = new Point( 5 , 5 ); // 文本位置点
string DrawText = 要绘制它的文本..;
gp.AddString(DrawText,font.FontFamily,( int )font.Style,font.Size,DrawLocation,StringFormat.GenericDefault);
}
gg.DrawPath(penDefault,gp);
祝你好运。
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);
}
try to use utf-8 special characters and draw it with your text..
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
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.
这篇关于printdocument中的Drawcheckbox C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!