设置PrintPreviewDialog控件的初始状态

时间:2022-09-20 15:54:14

I'm working with PrintPreviewDialog and want to tweak its initial presentation from the default. So far, I've done this:

我正在使用PrintPreviewDialog,并希望从默认情况调整其初始演示文稿。到目前为止,我已经这样做了:

            PrintPreviewDialog dlg = new PrintPreviewDialog();
            dlg.WindowState = FormWindowState.Maximized;
            dlg.PrintPreviewControl.Zoom = 1.0;

...which gives me the presentation I want, but when the dialog is opened, the zoom control has the "Auto" choice selected, not 100% as would correspond to the zoom value of 1.0. How can I get at the zoom control to show 100% as the currently selected zoom setting so as not to confuse the user?

...它给了我想要的演示文稿,但是当打开对话框时,缩放控件选择了“自动”选项,而不是100%,与缩放值1.0相对应。如何在变焦控制中显示100%作为当前选择的缩放设置,以免混淆用户?

BTW, this is VS 2010 .NET 4

顺便说一句,这是VS 2010 .NET 4

1 个解决方案

#1


3  

Maybe setting AutoZoom = false will help:

也许设置AutoZoom = false会有所帮助:

dlg.PrintPreviewControl.AutoZoom = false;

The PrintPreviewControl should reflect the value of AutoZoom and Zoom but it doesn't. That's a strange thing in its design. However after a search on this control, I've found that we can access to the ToolStrip of the PrintPreviewDialog. This dialog has 2 child controls by default. The first is the PrintPreviewControl which is exposed via the property PrintPreviewControl, the second is the ToolStrip. By looping through the Items, you can find the exact ToolStripSplitButton (the Zoom button) and by looping through the DropDownItems of that splitbutton, we can find the exact 100% toolstripdropdownitem and call PerformClick to check it. However by default, I think we know the index of the item beforehand and the following code would work:

PrintPreviewControl应该反映AutoZoom和Zoom的值,但它不会。这在设计上是一件奇怪的事情。但是在搜索了这个控件之后,我发现我们可以访问PrintPreviewDialog的ToolStrip。默认情况下,此对话框有2个子控件。第一个是PrintPreviewControl,它通过属性PrintPreviewControl公开,第二个是ToolStrip。通过循环遍历Items,您可以找到确切的ToolStripSplitButton(缩放按钮),并通过循环遍历该splitbutton的DropDownItems,我们可以找到确切的100%toolstripdropdownitem并调用PerformClick进行检查。但是默认情况下,我认为我们事先知道项目的索引,以下代码可以工作:

ToolStripSplitButton zoomButton = ((ToolStrip)dlg.Controls[1]).Items[1] as ToolStripSplitButton;
zoomButton.DropDownItems[4].PerformClick();//Check the 100% item in the zoom list

#1


3  

Maybe setting AutoZoom = false will help:

也许设置AutoZoom = false会有所帮助:

dlg.PrintPreviewControl.AutoZoom = false;

The PrintPreviewControl should reflect the value of AutoZoom and Zoom but it doesn't. That's a strange thing in its design. However after a search on this control, I've found that we can access to the ToolStrip of the PrintPreviewDialog. This dialog has 2 child controls by default. The first is the PrintPreviewControl which is exposed via the property PrintPreviewControl, the second is the ToolStrip. By looping through the Items, you can find the exact ToolStripSplitButton (the Zoom button) and by looping through the DropDownItems of that splitbutton, we can find the exact 100% toolstripdropdownitem and call PerformClick to check it. However by default, I think we know the index of the item beforehand and the following code would work:

PrintPreviewControl应该反映AutoZoom和Zoom的值,但它不会。这在设计上是一件奇怪的事情。但是在搜索了这个控件之后,我发现我们可以访问PrintPreviewDialog的ToolStrip。默认情况下,此对话框有2个子控件。第一个是PrintPreviewControl,它通过属性PrintPreviewControl公开,第二个是ToolStrip。通过循环遍历Items,您可以找到确切的ToolStripSplitButton(缩放按钮),并通过循环遍历该splitbutton的DropDownItems,我们可以找到确切的100%toolstripdropdownitem并调用PerformClick进行检查。但是默认情况下,我认为我们事先知道项目的索引,以下代码可以工作:

ToolStripSplitButton zoomButton = ((ToolStrip)dlg.Controls[1]).Items[1] as ToolStripSplitButton;
zoomButton.DropDownItems[4].PerformClick();//Check the 100% item in the zoom list