不明白你要干什么?
string s=(WebBrowser)sender)DocumentGetElementById("sljaqi")InnerHtml;
你要保存哪个变量?
Print()的内容是全部的源代码?
PrintDocument 的PrintPage ,BeginPrint , EndPrint事件,至于打印队列,交给系统驱动去处理,不需要自己来处理,自己写代码还未必比系统默认处理的要好,如果真的要这么做,就去找SDK上的API了。
1:删除打印任务
2:开始→设置→管理工具→服务,找到Print Spooler,双击,在常规里面点停止
3:然后点开始→运行,输入Spool,打开PRINTERS文件夹,将里面的东西全部删除,然后再在常规选项卡里点启动→print Spooler 打印服务
4:把打印机电源断开一分钟,再接上及重起电脑 (一定要做哦)
1、将需要打印的打印机设为默认打印机;
2、从开始-设置-打印机传真机-打开打印机选项 打印机有没有选择暂停打印;如果有去掉此选项;
3、有远程文档打印,因缺纸呀什么的没有及时出来,造成文档积压。一般关闭打印机,从开始-设置-打印机传真机-打开打印机选项,选择文档右击取消 再打印就行了;
4、驱动安装有问题:设备管理器-通用串行总线控制器-打印机选项(不同的打印机应该也不一样) 把他删掉,重新装一下驱动就行了。
5、端口选择错误:从开始-设置-打印机传真机,右击打印机-属性-端口选项卡,看看是不是设置正确,我们的这个HP1020的是USB1
首先 using SystemDrawingPrinting;
@@@@@@@@这个一定要注意 不然没法用的 要报错 如果觉得对你有帮助 给分吧
以下为参考
//
//
// 打印相关(以下部分)
//
//
private DataTable dtStudent; //存放需打印的学生ID列表
private int intIndex = 0; //当前打印序号
//打印所选班级
private void btnPrintClassroom_Click(object sender, EventArgs e)
{
if (clbClassroomItemsCount == 0) return; //无班级列表则不能打印
//初始化打印学生数据表
intIndex = 0;
dtStudent = new DataTable();
dtStudentColumnsAdd("Id", typeof(string));
string strClassroomId;
string strSql;
OleDbConnection conn = new OleDbConnection(SqlHelperconnStr);
connOpen();
OleDbCommand cmd;
OleDbDataReader dr;
//若没有复选,则打印选择项
if (clbClassroomCheckedItemsCount == 0)
{
strSql = "select Id from Student where ClassroomId='" + clbClassroomSelectedValueToString() + "'";
cmd = new OleDbCommand(strSql, conn);
dr = cmdExecuteReader();
while (drRead())
{
DataRow drow = dtStudentNewRow();
string strStudentId = dr["Id"]ToString();
StudentInfo si = new StudentInfo(strStudentId);
//若选择了只打带毕业证号并且有毕业证号 或者 没有选择只打带毕业证号的,则打印
if (chbOnlyPrintDiplomaNoChecked && siDiplomaNoTrim() != "" || !chbOnlyPrintDiplomaNoChecked)
{
drow["Id"] = strStudentId;
dtStudentRowsAdd(drow);
}
}
drClose();
}
foreach (SystemDataDataRowView item in clbClassroomCheckedItems)
{
strClassroomId = itemRow["Id"]ToString();
strSql = "select Id from Student where ClassroomId='" + strClassroomId + "'";
cmd = new OleDbCommand(strSql, conn);
dr = cmdExecuteReader();
while (drRead())
{
DataRow drow = dtStudentNewRow();
string strStudentId = dr["Id"]ToString();
StudentInfo si = new StudentInfo(strStudentId);
//若选择了只打带毕业证号并且有毕业证号 或者 没有选择只打带毕业证号的,则打印
if (chbOnlyPrintDiplomaNoChecked && siDiplomaNoTrim() != "" || !chbOnlyPrintDiplomaNoChecked)
{
drow["Id"] = strStudentId;
dtStudentRowsAdd(drow);
}
}
drClose();
}
connClose();
//初始化进度条
pbMinimum = 0;
pbMaximum = dtStudentRowsCount;
pbValue = 0;
pbStep = 1;
if (dtStudentRowsCount > 0)
{
printDocumentPrint();
}
else
{
MessageBoxShow("没有满足打印条件的数据!");
}
}
//打印所选学生
private void btnPrintStudent_Click(object sender, EventArgs e)
{
if (clbStudentItemsCount == 0) return; //无学生列表则不能打印
//初始化打印学生数据表
intIndex = 0;
dtStudent = new DataTable();
dtStudentColumnsAdd("Id", typeof(string));
//若没有复选,则打印选择学生项
if (clbStudentCheckedItemsCount == 0)
{
DataRow drow = dtStudentNewRow();
drow["Id"] = clbStudentSelectedValueToString();
dtStudentRowsAdd(drow);
}
foreach (SystemDataDataRowView item in clbStudentCheckedItems)
{
DataRow drow = dtStudentNewRow();
string strStudentId = item["Id"]ToString();
StudentInfo si = new StudentInfo(strStudentId);
//若选择了只打带毕业证号并且有毕业证号 或者 没有选择只打带毕业证号的,则打印
if (chbOnlyPrintDiplomaNoChecked && siDiplomaNoTrim() != "" || !chbOnlyPrintDiplomaNoChecked)
{
drow["Id"] = strStudentId;
dtStudentRowsAdd(drow);
}
}
//初始化进度条
pbMinimum = 0;
pbMaximum = dtStudentRowsCount;
pbValue = 0;
pbStep = 1;
if (dtStudentRowsCount > 0)
{
printDocumentPrint();
}
else
{
MessageBoxShow("没有满足打印条件的数据!");
}
}
//打印预览
private void btnPrintPreview_Click(object sender, EventArgs e)
{
if (clbStudentItemsCount == 0) return; //无学生列表则不能打印
//初始化打印学生数据表
intIndex = 0;
dtStudent = new DataTable();
dtStudentColumnsAdd("Id", typeof(string));
//若没有复选,则打印预览选择学生项
if (clbStudentCheckedItemsCount == 0)
{
DataRow drow = dtStudentNewRow();
drow["Id"] = clbStudentSelectedValueToString();
dtStudentRowsAdd(drow);
}
foreach (SystemDataDataRowView item in clbStudentCheckedItems)
{
DataRow drow = dtStudentNewRow();
string strStudentId = item["Id"]ToString();
StudentInfo si = new StudentInfo(strStudentId);
//若选择了只打带毕业证号并且有毕业证号 或者 没有选择只打带毕业证号的,则打印
if (chbOnlyPrintDiplomaNoChecked && siDiplomaNoTrim() != "" || !chbOnlyPrintDiplomaNoChecked)
{
drow["Id"] = strStudentId;
dtStudentRowsAdd(drow);
}
}
if (dtStudentRowsCount > 0)
{
printPreviewDialog1Document = printDocument;
printPreviewDialog1ShowDialog();
}
else
{
MessageBoxShow("没有满足打印条件的数据!");
}
}
//打印设置
private void btnPrintSetup_Click(object sender, EventArgs e)
{
printDialog1Document = printDocument;
if (printDialog1ShowDialog() == DialogResultOK)
{
printDocumentPrint();
}
}
//设置打印学生成绩内容
private void printDocument_PrintPage(object sender, PrintPageEventArgs e)
{
lblStateText = "打印处理中,请等候[" + intIndexToString() + "/" + dtStudentRowsCountToString() + "]";
ApplicationDoEvents();
if (intIndex < dtStudentRowsCount)
{
string strStudentId = dtStudentRows[intIndex]["Id"]ToString();
printContent(sender, e, strStudentId);
}
pbPerformStep();
intIndex++;
if (intIndex < dtStudentRowsCount)
{
eHasMorePages = true;
}
else
{
lblStateText = "打印完成";
eHasMorePages = false;
}
}
//打印内容设置函数
private void printContent(object sender, PrintPageEventArgs e, string StudentId)
{
int x, y, w, h, l, t; //坐标,宽、高、左、上
x = eMarginBoundsX;
y = eMarginBoundsY;
w = eMarginBoundsWidth;
h = eMarginBoundsHeight;
l = eMarginBoundsLeft;
t = eMarginBoundsTop;
int rowSpan = ToolsIsNumeric( cbxRowSpanText ); //行间距
int xLeft = x + 20; //左边距
int xRight = 760 -20 ; //右边距
int intRemark = 0; //该生有几科不正常成绩
//获取学生基本信息
StudentInfo si = new StudentInfo(StudentId);
//设置Graphics实例
Graphics g = eGraphics;
//画笔普通
Pen pen = new Pen(ColorBlack);
//画笔重
Pen penStrong = new Pen(ColorBlack,2);
//字体(表头,即大标题)
Font fontHead = new Font(new FontFamily("宋体"), 17, FontStyleBold);
//字体(小标题,即姓名、班级、落款等)
Font fontCaption = new Font(new FontFamily("宋体"), 12);
//字体(小表头,即序号,课程名等)
Font fontBodyTitle = new Font(new FontFamily("黑体"), 10);
//字体(正文)
Font fontBody = new Font(new FontFamily("宋体"), 10);
//表头
string strHead="XX学院" + siJieToString() + "届毕业生成绩单";
gDrawString(strHead, fontHead, BrushesBlack, xLeft + (xRight-xLeft)/2 -strHeadLengthfontHeadHeight /2 + 20, y);
xLeft = xLeft - 30;
y = y + ConvertToInt32( fontHeadHeight 25);
//姓名,专业班级,制表日期
gDrawString("姓名:" + siStudentName, fontCaption, BrushesBlack, xLeft, y);
//是否打印毕业z书号 ,同时考虑专业班级的位置对称
if (chbPrintDiplomaNoChecked)
{
gDrawString("专业班级:" + siClassroom, fontCaption, BrushesBlack, xLeft + 140, y);
if (siClassroomLength < 11)
{
gDrawString("毕业证号:" + siDiplomaNo, fontCaption, BrushesBlack, xLeft + 390, y);
}
else
{
y = y + ConvertToInt32(fontCaptionHeight 11);
gDrawString("毕业证号:" + siDiplomaNo, fontCaption, BrushesBlack, xLeft+140, y);
}
}
else
{
gDrawString("专业班级:" + siClassroom, fontCaption, BrushesBlack, xLeft + 330, y);
}
y = y + ConvertToInt32(fontCaptionHeight15);
gDrawLine(penStrong, xLeft, y, xRight, y); //加水平线
int yStart = y;
y = y + rowSpan;
gFillRectangle(BrushesGray, xLeft, y-1, xRight-xLeft, fontBodyTitleHeight+2 );
//左成绩表头
gDrawString("序号", fontBodyTitle, BrushesBlack, xLeft, y);
gDrawString("科目", fontBodyTitle, BrushesBlack, xLeft + 60, y);
gDrawString("成绩", fontBodyTitle, BrushesBlack, xLeft + 245, y);
//右成绩表头
gDrawString("序号", fontBodyTitle, BrushesBlack, xLeft + (xRight - xLeft) / 2 , y);
gDrawString("科目", fontBodyTitle, BrushesBlack, xLeft + (xRight - xLeft) / 2 + 60, y);
gDrawString("成绩", fontBodyTitle, BrushesBlack, xLeft + (xRight - xLeft) / 2 + 245, y);
y =y+ fontBodyTitleHeight +rowSpan ;
gDrawLine(penStrong, xLeft, y, xRight, y);
y = y + rowSpan;
int intNo = 1; //课程序号
for (int i = 0; i < siTermCount; i++)
{
//gFillRectangle(BrushesLightGray, xLeft, y, xRight2, fontBodyHeight);
gDrawString("第" + (i + 1)ToString() + "学期(" + siarrTerm[i] + ")", fontBodyTitle, BrushesBlack, xLeft, y);
y = y + fontBodyTitleHeight + rowSpan;
gDrawLine(pen, xLeft, y, xRight, y); //加水平线
y = y + rowSpan;
DataView dv = sidtScoreDefaultView;
dvRowFilter = "Term='" + siarrTerm[i] + "'";
for (int j = 0; j < dvCount; j++)
{
//第一列成绩
if (dv[j]["Score"]ToString()=="" && dv[j]["Remark"]ToString() != "") //取非正常成绩
{
intRemark ++;
}
gDrawString((intNo++)ToString() + "" , fontBody, BrushesBlack, xLeft+5, y);
gDrawString( dv[j]["Course"]ToString() + ":", fontBody, BrushesBlack, xLeft+25, y);
gDrawString(dv[j]["Score"]ToString(), fontBody, BrushesBlack, xLeft + 250, y);
//第二列成绩
if (++j < dvCount)
{
if (dv[j]["Score"]ToString() == "" && dv[j]["Remark"]ToString() != "")
{
intRemark++;
}
gDrawString((intNo++)ToString() + "", fontBody, BrushesBlack, xLeft + (xRight - xLeft) / 2+10, y);
gDrawString(dv[j]["Course"]ToString(), fontBody, BrushesBlack, xLeft + (xRight - xLeft) / 2 +10 + 25, y);
gDrawString(dv[j]["Score"]ToString(), fontBody, BrushesBlack, xLeft + (xRight - xLeft) / 2 + 250, y);
}
y = y + fontBodyHeight+rowSpan ;
}
if (i < siTermCount-1)
{
gDrawLine(pen, xLeft, y, xRight, y); //加水平线
}
y = y + rowSpan;
}
gDrawLine(penStrong, xLeft, y, xRight, y); //加水平线
gDrawLine(penStrong, xLeft, yStart, xLeft, y); //加左竖线
gDrawLine(pen, xLeft + (xRight - xLeft) / 2, yStart, xLeft + (xRight - xLeft) / 2, y); //加中竖线
gDrawLine(penStrong, xRight, yStart, xRight, y); //加右竖线
//选择合适的打印页脚的位置
if (y < (t + h)) //若剩余空行多,就在之间打印页脚
{
y=ConvertToInt32( y+(t + h-y )05);
if (intRemark > 0)
{
gFillRectangle(BrushesGray, xLeft + 20, y, fontCaptionHeight2, fontCaptionHeight);
gDrawString(intRemarkToString(), fontCaption, BrushesBlack, xLeft + 20, y);
}
gDrawString("XX学院学生处", fontCaption, BrushesBlack, xLeft + 400, y);
y = y + 20;
gDrawString("制表日期: " + SystemDateTimeNowToShortDateString(), fontCaption, BrushesBlack, xLeft + 435, y);
}
else //否则在页底打印页脚
{
if (intRemark > 0)
{
gFillRectangle(BrushesGray, xLeft + 20, y, fontCaptionHeight 2, fontCaptionHeight);
gDrawString(intRemarkToString(), fontCaption, BrushesBlack, xLeft + 20, y);
}
gDrawString("XX学院学生处", fontCaption, BrushesBlack, xLeft + 200, y + 5);
gDrawString("制表日期: " + SystemDateTimeNowToShortDateString(), fontCaption, BrushesBlack, xLeft + 450, y + 5);
}
}
private void btnAbout_Click(object sender, EventArgs e)
{
AboutBox aboutBox = new AboutBox();
aboutBoxShowDialog(this);
}
1 打开Excel dim myexcelas new ExcelApplication() myexcelvisible=true
2 添加新的工作簿myexcelWorkbooksadd()
3 设定第二个工作表为活动工作表myexcelworksheets(2)Acivate()
4 打开指定的Excel文件myexcelworkbooksopen(“c:\myxls”)
5 显示Excel窗口myexcelvisible=true
6 更改Excel的标题栏myexcelcaption=“欢迎,欢迎!”
7 为Excel的单元格赋值myexcelcells(1,4)value=100 此语句使Excel当前工作表的第一行第四列,即D1单元格等于100, 也可以这样写: myexcelRange(“D1”)value=100
8 设置指定列的宽度(单位:字符个数)myexcelActiveSheetcolums(1)columnwidth=20 设定当前工作表第1列的宽度为20
9 设置指定行的高(单位:磅)myexcelActiveSheetrows(1)rowHeight=1/0035 1磅 =0035厘米设置第1行的高度为1CM
10 插入分页符 myexcelActivesheetrows(20)pagebreak=1在第20行前插入分页符
11 删除分页符myexcelActivesheetcolumns(20)pagebreak=0 在第20列前删除分页符
12 指定边框线的宽度myexcelActivesheetrange(“B3:D3”)borders(1)weight=3 其中borders参数指定单元格边框的位置:1:左 2:右 3:顶 4:底 5:斜\ 6:斜/
13 指定边框线条的类型 myexcelActivesheetrange(“B1:D3”)borders(2)linestyle=1此语句将当前工作表的B1:D3单元格的右边框设置为实线 linestyle参数: 1:细实线 2:细虚线 3:点虚线 4:双细实线
14 设置页脚myexcelactivesheetpagesetupcenterfooter=“第&p页” 注意:设置页眉页脚时要保证计算机上装有打印机,否则出错!
15 设置页眉myexcelactivesheetpagesetupcenterfooter=“第&p页”
16 设置页眉到顶断距离为2cmmyexcelActivesheetpagesetupHeadermargin=2/0035
17 设置页脚到底端距离为2cmmyexcelActivesheetpagesetupFootermargin=2/0035
18 设置顶边边距为2cmmyexcelActivesheetpagesetuptopmargin=2/0035
19 设置底边边距为2cmmyexcelActivesheetpagesetupBottommargin=2/0035
20 设置左边边距为2cmmyexcelActivesheetpagesetupLeftmargin=2/0035
21 设置右边边距为2cmmyexcelActivesheetpagesetupRightmargin=2/0035
22 设置页面水平居中myexcelactivesheetpagesetupCenterHorizontally=true
23 设置页面垂直居中myexcelactivesheetpagesetupCentervertically=true
24 设置页面纸张大小 (1,窄行8511 ;39 ,宽行1411) myexcelactivesheetpagesetuppapersize=1
25 打印单元格网格线 myexcelactivesheetpagesetupPrintGridlines=true
26 复制整个工作表 myexcelactivesheetUsedrangeCopy
27 复制指定区域 myexcelactivesheetrange(“a1:b5”)Copy
28 粘贴 myexcelworksheets(“sheet2”)range(“A1”)PasteSpecial
29 在第2行前插入一行 myexcelactivesheetrows(2)Insert
30 在第2列前插入一列 myexcelActivesheetColumns(2)Insert
31 合并 C4:D4 单元格 myexcelActivesheetRange(“C4:D4”)Merge()
32 自动调整第2列列宽 myexcelactivesheetColumns(2)AutoFit
33 设置字体myexcelActivesheetcells(2,1)fontname=“黑体”
34 设置字体大小myexcelActivesheetcells(2,1)fontsize=25
35 设置字体为斜体 myexcelActivesheetcells(2,1)fontItalic=true
36 设置字体为粗体 myexcelActivesheetcells(2,1)fontBold=true
37 清除单元格内容myexcelactivesheetcells(2,1)ClearContents
38 打印预览工作表myexcelActivesheetPrintPreview
39 打印工作表 myexcelActivesheetPrintout
40 工作表另存为myexcelActiveWorkbooksaveas(“C:\book2xls”)
41 放弃存盘 myexcelActiveWorkbooksaved=false
42 关闭工作簿 myexcelWorkbooksclose
43 退出 Excel myexcelquit
44 纸张横向:myexcelactivesheetPageSetupOrientaTion=2(1纵向)
45 单元格居中:cells(2,1)HorizontalAlignment=ExcelXlHAlignxlHAlignCenter 水平方向cells(2,1)VerticalAlignment=ExcelXlVAlignxlVAlignCenter 垂直方向
打开CSDN APP,看更多技术内容
VB调用Excel软件实现打印预览功能
摘要:VB源码,报表打印,打印预览VB调用Excel软件实现打印预览功能,可以插入折线图,VB打印预览功能示例源码,分享给大家参考。
用vb *** 作EXCEL打印报表
最近使用vb来打印报表,打印出来的EXCEL一直无法上传到ftp 反复多次问题都没解决, 200 PORT command successful Consider using PASV 问题出在这,由于win10的防火墙的原因,关闭防火墙后问题得到解决 转载于:>
using System;
using SystemCollectionsGeneric;
using SystemComponentModel;
using SystemData;
using SystemDrawing;
using SystemText;
using SystemWindowsForms;
using SystemDataSqlClient;
using SystemDrawingPrinting;
namespace StudentManager
{
public partial class PrintGridView : Form
{
string sSqlConnection = @"Data Source=local;Initial Catalog=StudentManager;User ID=sa;Password=123456";
//打印文档
PrintDocument pdDocument = new PrintDocument();
//打印格式设置页面
PageSetupDialog dlgPageSetup = new PageSetupDialog();
//打印页面
PrintDialog dlgPrint = new PrintDialog();
private Button btnPrint;
private Button btnPrintView;
private DataGridView dgvData;
private PrintPreviewDialog printPreviewDialog1;
private PrintDocument printDocument1;
//实例化打印预览
PrintPreviewDialog dlgPrintPreview = new PrintPreviewDialog();
public PrintGridView()
{
InitializeComponent();
btnPrintClick += new EventHandler(btnPrint_Click);
btnPrintViewClick += new EventHandler(btnPrintView_Click);
pdDocumentPrintPage += new PrintPageEventHandler(OnPrintPage);
//页面设置的打印文档设置为需要打印的文档
dlgPageSetupDocument = pdDocument;
//打印界面的打印文档设置为被打印文档
dlgPrintDocument = pdDocument;
//打印预览的打印文档设置为被打印文档
dlgPrintPreviewDocument = pdDocument;
GetData();
}
///
/// 打印预览
///
///
///
void btnPrintView_Click(object sender, EventArgs e)
{
//显示打印预览界面
dlgPrintPreviewShowDialog();
}
private void GetData()
{
SqlConnection scConnect = new SqlConnection(sSqlConnection);
scConnectOpen();
SqlCommand scCommand = scConnectCreateCommand();
scCommandCommandText = "select customerID,companyName from customers";
SqlDataAdapter sdaAdapter = new SqlDataAdapter(scCommand);
DataTable dt = new DataTable();
sdaAdapterFill(dt);
dgvDataDataSource = dt;
scCommandDispose();
scConnectClose();
sdaAdapterDispose();
}
///
/// DataGridView转换为二维数组
///
///
///
///
private string[,] ToStringArray(DataGridView dataGridView, bool includeColumnText)
{
string[,] arrReturn = null;
int rowsCount = dataGridViewRowsCount;
int colsCount = dataGridViewColumnsCount;
if (rowsCount > 0)
{
//最后一行是供输入的行时,不用读数据。
if (dataGridViewRows[rowsCount - 1]IsNewRow)
{
rowsCount--;
}
}
int i = 0;
//包括列标题
if (includeColumnText)
{
rowsCount++;
arrReturn = new string[rowsCount, colsCount];
for (i = 0; i < colsCount; i++)
{
arrReturn[0, i] = dataGridViewColumns[i]HeaderText;
}
i = 1;
}
else
{
arrReturn = new string[rowsCount, colsCount];
}
//读取单元格数据
int rowIndex = 0;
for (; i < rowsCount; i++, rowIndex++)
{
for (int j = 0; j < colsCount; j++)
{
arrReturn[i, j] = dataGridViewRows[rowIndex]Cells[j]ValueToString();
}
}
return arrReturn;
}
///
/// 打印
///
///
///
void btnPrint_Click(object sender, EventArgs e)
{
pdDocumentPrint();
}
///
/// printDocument的PrintPage事件
///
///
///
private void OnPrintPage(object sender, PrintPageEventArgs e)
{
int iX = 10;
int iY = 10;
printdatagridprint(dgvData, true, e, ref iX, ref iY);
}
///
/// EndPrint事件释放BeginPrint方法中占用的资源
///
///
///
void pdDocument_EndPrint(object sender, PrintEventArgs e)
{
}
private void InitializeComponent()
{
SystemComponentModelComponentResourceManager resources = new SystemComponentModelComponentResourceManager(typeof(PrintGridView));
thisbtnPrint = new SystemWindowsFormsButton();
thisbtnPrintView = new SystemWindowsFormsButton();
thisdgvData = new SystemWindowsFormsDataGridView();
thisprintPreviewDialog1 = new SystemWindowsFormsPrintPreviewDialog();
thisprintDocument1 = new SystemDrawingPrintingPrintDocument();
((SystemComponentModelISupportInitialize)(thisdgvData))BeginInit();
thisSuspendLayout();
//
// btnPrint
//
thisbtnPrintLocation = new SystemDrawingPoint(482, 73);
thisbtnPrintName = "btnPrint";
thisbtnPrintSize = new SystemDrawingSize(75, 23);
thisbtnPrintTabIndex = 0;
thisbtnPrintText = "button1";
thisbtnPrintUseVisualStyleBackColor = true;
//
// btnPrintView
//
thisbtnPrintViewLocation = new SystemDrawingPoint(482, 168);
thisbtnPrintViewName = "btnPrintView";
thisbtnPrintViewSize = new SystemDrawingSize(75, 23);
thisbtnPrintViewTabIndex = 1;
thisbtnPrintViewText = "button2";
thisbtnPrintViewUseVisualStyleBackColor = true;
//
// dgvData
//
thisdgvDataColumnHeadersHeightSizeMode = SystemWindowsFormsDataGridViewColumnHeadersHeightSizeModeAutoSize;
thisdgvDataLocation = new SystemDrawingPoint(-3, 12);
thisdgvDataName = "dgvData";
thisdgvDataRowTemplateHeight = 23;
thisdgvDataSize = new SystemDrawingSize(408, 440);
thisdgvDataTabIndex = 2;
//
// printPreviewDialog1
//
thisprintPreviewDialog1AutoScrollMargin = new SystemDrawingSize(0, 0);
thisprintPreviewDialog1AutoScrollMinSize = new SystemDrawingSize(0, 0);
thisprintPreviewDialog1ClientSize = new SystemDrawingSize(400, 300);
thisprintPreviewDialog1Enabled = true;
thisprintPreviewDialog1Icon = ((SystemDrawingIcon)(resourcesGetObject("printPreviewDialog1Icon")));
thisprintPreviewDialog1Name = "printPreviewDialog1";
thisprintPreviewDialog1Visible = false;
//
// PrintGridView
//
thisClientSize = new SystemDrawingSize(787, 527);
thisControlsAdd(thisdgvData);
thisControlsAdd(thisbtnPrintView);
thisControlsAdd(thisbtnPrint);
thisName = "PrintGridView";
((SystemComponentModelISupportInitialize)(thisdgvData))EndInit();
thisResumeLayout(false);
}
}
/////
///// 实现DataGridView的打印
/////
//public class PrintDataGridView
//{
// private static List CellPrintList = new List();
// private static int printRowCount = 0;
// private static bool IsPrint = true;
// private static bool IsRole = true;
// private static int PoXTmp = 0;
// private static int PoYTmp = 0;
// private static int WidthTmp = 0;
// private static int HeightTmp = 0;
// private static int RowIndex = 0;
// ///
// /// 打印DataGridView控件
// ///
// /// DataGridView控件
// /// 是否包括列标题
// /// 为 SystemDrawingPrintingPrintDocumentPrintPage 事件提供数据。
// /// 起始X坐标
// /// 起始Y坐标
// public static void Print(DataGridView dataGridView, bool includeColumnText, PrintPageEventArgs eValue, ref int PoX, ref int PoY)
// {
// try
// {
// if (PrintDataGridViewIsPrint)
// {
// PrintDataGridViewprintRowCount = 0;
// PrintDataGridViewIsPrint = false;
// PrintDataGridViewDataGridViewCellVsList(dataGridView, includeColumnText);
// if (0 == PrintDataGridViewCellPrintListCount)
// return;
// if (PoX > eValueMarginBoundsLeft)
// PrintDataGridViewIsRole = true;
// else
// PrintDataGridViewIsRole = false;
// PrintDataGridViewPoXTmp = PoX;
// PrintDataGridViewPoYTmp = PoY;
// PrintDataGridViewRowIndex = 0;
// WidthTmp = 0;
// HeightTmp = 0;
// }
// if (0 != PrintDataGridViewprintRowCount)
// {
// if (IsRole)
// {
// PoX = PoXTmp = eValueMarginBoundsLeft;
// PoY = PoYTmp = eValueMarginBoundsTop;
// }
// else
// {
// PoX = PoXTmp;
// PoY = PoYTmp;
// }
// }
// while (PrintDataGridViewprintRowCount < PrintDataGridViewCellPrintListCount)
// {
// DataGridViewCellPrint CellPrint = CellPrintList[PrintDataGridViewprintRowCount];
// if (RowIndex == CellPrintRowIndex)
// PoX = PoX + WidthTmp;
// else
// {
// PoX = PoXTmp;
// PoY = PoY + HeightTmp;
// if (PoY + HeightTmp > eValueMarginBoundsBottom)
// {
// HeightTmp = 0;
// eValueHasMorePages = true;
// return;
// }
// }
// using (SolidBrush solidBrush = new SolidBrush(CellPrintBackColor))
// {
// RectangleF rectF1 = new RectangleF(PoX, PoY, CellPrintWidth, CellPrintHeight);
// eValueGraphicsFillRectangle(solidBrush, rectF1);
// using (Pen pen = new Pen(ColorBlack, 1))
// eValueGraphicsDrawRectangle(pen, RectangleRound(rectF1));
// solidBrushColor = CellPrintForeColor;
// eValueGraphicsDrawString(CellPrintFormattedValue, CellPrintFont, solidBrush, new Point(PoX + 2, PoY + 3));
// }
// WidthTmp = CellPrintWidth;
// HeightTmp = CellPrintHeight;
// RowIndex = CellPrintRowIndex;
// PrintDataGridViewprintRowCount++;
// }
// PoY = PoY + HeightTmp;
// eValueHasMorePages = false;
// PrintDataGridViewIsPrint = true;
// }
// catch
// {
// eValueHasMorePages = false;
// PrintDataGridViewIsPrint = true;
// throw;
// }
// }
// ///
// /// 将DataGridView控件内容转变到 CellPrintList
// ///
// /// DataGridView控件
// /// 是否包括列标题
// private static void DataGridViewCellVsList(DataGridView dataGridView, bool includeColumnText)
// {
// CellPrintListClear();
// try
// {
// int rowsCount = dataGridViewRowsCount;
// int colsCount = dataGridViewColumnsCount;
// //最后一行是供输入的行时,不用读数据。
// if (dataGridViewRows[rowsCount - 1]IsNewRow)
// rowsCount--;
// //包括列标题
// if (includeColumnText)
// {
// for (int columnsIndex = 0; columnsIndex < colsCount; columnsIndex++)
// {
// if (dataGridViewColumns[columnsIndex]Visible)
// {
// DataGridViewCellPrint CellPrint = new DataGridViewCellPrint();
// CellPrintFormattedValue = dataGridViewColumns[columnsIndex]HeaderText;
// CellPrintRowIndex = 0;
// CellPrintColumnIndex = columnsIndex;
// CellPrintFont = dataGridViewColumns[columnsIndex]HeaderCellStyleFont;
// CellPrintBackColor = dataGridViewColumnHeadersDefaultCellStyleBackColor;
// CellPrintForeColor = dataGridViewColumnHeadersDefaultCellStyleForeColor;
// CellPrintWidth = dataGridViewColumns[columnsIndex]Width;
// CellPrintHeight = dataGridViewColumnHeadersHeight;
// CellPrintListAdd(CellPrint);
// }
// }
// }
// //读取单元格数据
// for (int rowIndex = 0; rowIndex < rowsCount; rowIndex++)
// {
// for (int columnsIndex = 0; columnsIndex < colsCount; columnsIndex++)
// {
// if (dataGridViewColumns[columnsIndex]Visible)
// {
// DataGridViewCellPrint CellPrint = new DataGridViewCellPrint();
// CellPrintFormattedValue = dataGridViewRows[rowIndex]Cells[columnsIndex]FormattedValueToString();
// if (includeColumnText)
// CellPrintRowIndex = rowIndex + 1;//假如包括列标题则从行号1开始
// else
// CellPrintRowIndex = rowIndex;
// CellPrintColumnIndex = columnsIndex;
// CellPrintFont = dataGridViewRows[rowIndex]Cells[columnsIndex]StyleFont;
// SystemDrawingColor TmpColor = SystemDrawingColorEmpty;
// if (SystemDrawingColorEmpty != dataGridViewRows[rowIndex]Cells[columnsIndex]StyleBackColor)
// TmpColor = dataGridViewRows[rowIndex]Cells[columnsIndex]StyleBackColor;
// else if (SystemDrawingColorEmpty != dataGridViewRows[rowIndex]DefaultCellStyleBackColor)
// TmpColor = dataGridViewRows[rowIndex]DefaultCellStyleBackColor;
// else
// TmpColor = dataGridViewDefaultCellStyleBackColor;
// CellPrintBackColor = TmpColor;
// TmpColor = SystemDrawingColorEmpty;
// if (SystemDrawingColorEmpty != dataGridViewRows[rowIndex]Cells[columnsIndex]StyleForeColor)
// TmpColor = dataGridViewRows[rowIndex]Cells[columnsIndex]StyleForeColor;
// else if (SystemDrawingColorEmpty != dataGridViewRows[rowIndex]DefaultCellStyleForeColor)
// TmpColor = dataGridViewRows[rowIndex]DefaultCellStyleForeColor;
// else
// TmpColor = dataGridViewDefaultCellStyleForeColor;
// CellPrintForeColor = TmpColor;
// CellPrintWidth = dataGridViewColumns[columnsIndex]Width;
// CellPrintHeight = dataGridViewRows[rowIndex]Height;
// CellPrintListAdd(CellPrint);
// }
// }
// }
// }
// catch { throw; }
// }
// private class DataGridViewCellPrint
// {
// private string _FormattedValue = "";
// private int _RowIndex = -1;
// private int _ColumnIndex = -1;
// private SystemDrawingColor _ForeColor = SystemDrawingColorBlack;
// private SystemDrawingColor _BackColor = SystemDrawingColorWhite;
// private int _Width = 100;
// private int _Height = 23;
// private SystemDrawingFont _Font = new SystemDrawingFont("宋体", 9F, SystemDrawingFontStyleRegular, SystemDrawingGraphicsUnitPoint, ((byte)(134)));
// ///
// /// 获取或设置单元格的字体。
// ///
// public SystemDrawingFont Font
// {
// set { if (null != value) _Font = value; }
// get { return _Font; }
// }
// ///
// /// 获取为显示进行格式化的单元格的值。
// ///
// public string FormattedValue
// {
// set { _FormattedValue = value; }
// get { return _FormattedValue; }
// }
// ///
// /// 获取或设置列的当前宽度 (以像素为单位)。默认值为 100。
// ///
// public int Width
// {
// set { _Width = value; }
// get { return _Width; }
// }
// ///
// /// 获取或设置列标题行的高度(以像素为单位)。默认值为 23。
// ///
// public int Height
// {
// set { _Height = value; }
// get { return _Height; }
// }
// ///
// /// 获取或设置行号。
// ///
// public int RowIndex
// {
// set { _RowIndex = value; }
// get { return _RowIndex; }
// }
// ///
// /// 获取或设置列号。
// ///
// public int ColumnIndex
// {
// set { _ColumnIndex = value; }
// get { return _ColumnIndex; }
// }
// ///
// /// 获取或设置前景色。
// ///
// public SystemDrawingColor ForeColor
// {
// set { _ForeColor = value; }
// get { return _ForeColor; }
// }
// ///
// /// 获取或设置背景色。
// ///
// public SystemDrawingColor BackColor
// {
// set { _BackColor = value; }
// get { return _BackColor; }
// }
// }
//}
}
以上就是关于C#如何获取((WebBrowser)sender).Print()内容全部的内容,包括:C#如何获取((WebBrowser)sender).Print()内容、C#如何动态的监控打印队列的状态,包括打印开始,打印结束时给用户提示,如何获取打印份数、wiform 打印问题等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)