如果您只需要一个或两个标题或一个条形码列的字体,那么您可以在图像类型的数据集上创建一个列,并将图像预先设置为文本到位图
// From dreaming in code
/// <summary>
/// Function for converting text to a Bitmap object
/// </summary>
/// <param name="width">Width of the image</param>
/// <param name="height">Height of the image</param>
/// <param name="str">String to be converted</param>
/// <param name="textColor">Color we want the text</param>
/// <param name="recColor">Color we want the background</param>
/// <param name="f">Name of the font we want used</param>
/// <returns></returns>
/// <remarks></remarks>
public Bitmap ConvertTextToBitmap(ref int width, ref int height, ref string str, ref Color textColor, ref Brush recColor, ref string fontName)
{
using (Bitmap bmp = new Bitmap(width, height))
{
using (Graphics gfx = Graphics.FromImage((Image)bmp))
{
gfx.SmoothingMode = SmoothingMode.AntiAlias;
Font font = new Font(fontName, 11, FontStyle.Regular, GraphicsUnit.Pixel);
gfx.FillRectangle(Brushes.Transparent, new Rectangle(0, 0, bmp.Width, bmp.Height));
gfx.FillRectangle(recColor, 0, 0, width, height);
gfx.DrawString(str, font, new SolidBrush(textColor), 2, 3);
bmp.Save(Application.StartupPath + "\\" + str + ".bmp", ImageFormat.Bmp);
return bmp;
}
}
}
您还可以创建一个自定义报表项来替换默认的文本框等,但从所有经验来看,这是一个很大的陷阱