使用了无效参数,是什么原因?

softmse 2005-12-30 12:03:44

//打印预览
public void printerView(Panel mainpanel,PictureBox[] mypb,bool rst)
{
this.currentPage = 1;
getTableValue(mainpanel,mypb);
try
{
PrintDocument pd = new PrintDocument();
pd.QueryPageSettings+= new QueryPageSettingsEventHandler(this.QueryPageSettingsEventHandler );
pd.PrintPage += new PrintPageEventHandler( this.PrintPageEventHandler);


Bitmap img=new Bitmap(mainpanel.AutoScrollMinSize.Width,mainpanel.AutoScrollMinSize.Height);
Graphics imgG=Graphics.FromImage(img);
imgG.Clear(mainpanel.BackColor);
if (rst)
{
printerp_Paint(mainpanel,new PaintEventArgs(imgG,mainpanel.ClientRectangle));
}
else
{
printer_Paint(mainpanel,new PaintEventArgs(imgG,mainpanel.ClientRectangle));
}
if ( this.storedPageSettings != null )
pd.DefaultPageSettings = this.storedPageSettings ;
PrintPreviewDialog dlg = new PrintPreviewDialog();
dlg.Document = pd;
dlg.ShowDialog();
}
运行到Bitmap img=new Bitmap(mainpanel.AutoScrollMinSize.Width,mainpanel.AutoScrollMinSize.Height);出错,是何原因?

...全文
189 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
疯狂Rabbit 2005-12-30
  • 打赏
  • 举报
回复
你可以查看一下,mainpanel.AutoScrollMinSize.Width和mainpanel.AutoScrollMinSize.Height如果你没有在之前给这个属性赋过值,那么它是0,当然会报错。

111,098

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧