打印 DataGridView
我设置了我的表格 DataGridView 通过预订,目前我可以打印 DataGridView, 但只有在显示屏上显示的内容,因此才会在滚动下打印时可见的任何数据。
如何更改代码,以便在按下打印按钮时 /包括滚动时查看的数据/ 在页面上打印?
如何更改代码,以便在按下打印按钮时 /包括滚动时查看的数据/ 在页面上打印?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace project
{
public partial class frmViewBookings : Form
{
public frmViewBookings//
{
InitializeComponent//;
}
private void btnClose_Click/object sender, EventArgs e/
{
Form3 mainpage = new Form3//;
mainpage.Show//;
this.Close//;
}
private void frmViewBookings_Load/object sender, EventArgs e/
{
// TODO: This line of code loads data into the 'usersDataSet1.Booking' table. You can move, or remove it, as needed.
this.bookingTableAdapter.Fill/this.usersDataSet1.Booking/;
}
private void printDocument1_PrintPage/object sender, System.Drawing.Printing.PrintPageEventArgs e/
{
Bitmap bm = new Bitmap/this.dataGridView1.Width, this.dataGridView1.Height/;
this.dataGridView1.DrawToBitmap/bm, new Rectangle/0, 0, this.dataGridView1.Width, this.dataGridView1.Height//;
e.Graphics.DrawImage/bm, 0, 0/;
}
private void btnPrint_Click/object sender, EventArgs e/
{
printDocument1.Print//;
}
}
}
没有找到相关结果
已邀请:
1 个回复
诸葛浮云
赞同来自:
这就是我的方式: