private void button_Preview_Click(object sender, EventArgs e) { PrintClass dgp = new PrintClass(//对打印信息进行设置 this.dataGridView1, comboBox_PageSize.SelectedIndex, checkBox_Aspect.Checked); MSetUp(dgp);//记录窗体中打印信息的相关设置 string[] header = new string[dataGridView1.ColumnCount];//创建一个与数据列相等的字符串数组 for (int p = 0; p < dataGridView1.ColumnCount; p++)//记录所有列标题的名列 { header[p] = dataGridView1.Columns[p].HeaderCell.Value.ToString(); } dgp.print();//显示打印预览窗体 }
private void button_Preview_Click(object sender, EventArgs e) { PrintClass dgp = new PrintClass(//对打印信息进行设置 this.dataGridView1, comboBox_PageSize.SelectedIndex, checkBox_Aspect.Checked); MSetUp(dgp); //记录窗体中打印信息的相关设置 string[] header = new string[dataGridView1.ColumnCount]; //创建一个与数据列相等的字符串数组 for (int p = 0; p < dataGridView1.ColumnCount; p++) //记录所有列标题的名列 { header[p] = dataGridView1.Columns[p].HeaderCell.Value.ToString(); } dgp.print();//显示打印预览窗体 }
/// <summary> /// 设置打印数据的相关信息 /// </summary> /// <param dgp="PrintClass">公共类PrintClass</param> private void MSetUp(PrintClass dgp) { dgp.PageAspect = Aspect;//设置横向打印 }