由于datagridview列太多,导致打印不完全,如何解决呢?
大体上就那么几种思路
1.缩小列宽
2.横版打印
3.改纸张大小
分页打印,PrintDocument 对象有一个 NewPage 方法,可以另起一页
试着横板打印,还是太多的话就只能调整列的内容了
解决方案:利用反射设置DataGridView的双缓冲
public MainForm1()
{
//设置窗体的双缓冲
this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint, true);
this.UpdateStyles();
InitializeComponent();
Type dgvType = this.dataGridView1.GetType();
PropertyInfo pi = dgvType.GetProperty("DoubleBuffered",
BindingFlags.Instance | BindingFlags.NonPublic);
pi.SetValue(this.dataGridView1, true, null);