在 Spire.pdfViewer 的上方按钮栏里加一个自定义按钮,点击铺满屏幕显示PFD
时间: 2024-02-20 11:01:03 浏览: 192
要在Spire.pdfViewer控件的上方按钮栏里添加一个自定义按钮,可以按照以下步骤进行操作:
1. 打开窗体设计器,将一个Button控件拖拽到Spire.pdfViewer控件的上方,设置Button的Text为“铺满屏幕”或其他你想要的文本。
2. 右键单击Button控件,选择“属性”选项。
3. 在属性窗口中,找到“事件”选项卡,查找“Click”事件。
4. 双击“Click”事件或单击其旁边的“+”符号,在代码文件中创建一个新的Click事件处理程序。
5. 在Click事件处理程序中编写代码以实现铺满屏幕显示PDF的功能。你可以使用Spire.pdfViewer控件的ZoomMode属性来设置缩放模式,例如:
```
private void button1_Click(object sender, EventArgs e)
{
this.pdfViewer.ZoomMode = Spire.PdfViewer.Forms.ZoomMode.FullScreen;
}
```
6. 在窗体加载时,将Button控件添加到Spire.pdfViewer控件的ToolStrip控件中,例如:
```
private void Form1_Load(object sender, EventArgs e)
{
ToolStrip toolStrip = (ToolStrip)this.pdfViewer.Controls[1];
ToolStripButton toolStripButton = new ToolStripButton("铺满屏幕");
toolStripButton.Click += new EventHandler(button1_Click);
toolStrip.Items.Add(toolStripButton);
}
```
其中,this.pdfViewer.Controls[1]表示Spire.pdfViewer控件的ToolStrip控件。这段代码将创建一个新的ToolStripButton控件,并将其添加到ToolStrip控件中。
最后,编译并运行程序,你应该可以在Spire.pdfViewer控件的上方看到一个“铺满屏幕”的按钮。当你单击该按钮时,PDF将被缩放以适应整个屏幕。
阅读全文
相关推荐


















