简体   繁体   English

单击按钮处理事件

[英]Handling an event on click of a button

I am making a button in C# 4.0. 我在C#4.0中创建一个按钮。 I want to click this button and I want to open a dialog box inside the adobe reader. 我要单击此按钮,并要在Adobe Reader中打开一个对话框。 So I am making use of itextsharp also. 因此,我也正在使用itextsharp。 Please let me know what must I use to make this dialog box work? 请让我知道如何使用此对话框?

PushbuttonField button1 = new PushbuttonField(
    stamper.Writer,
    new Rectangle(90, 660, 140, 690), "Add Context");
button1.Text = "Add Context";

Assuming that you have inherited from the base Button class , you can do: 假设您已经继承自Button类的基类 ,则可以执行以下操作:

this.button1.Click += new EventHandler(button1_Click);
//there you have an event:
private void button1_Click(object sender, EventArgs e)
{
   //open the dialog box here...
}
button1.Text = "Add Context";
button1.Click += new EventHandler(button_Click);

protected void button_Click (object sender, EventArgs e)
{ 
//  perform necessary actions
}

The previous answers don't match the question. 先前的答案与问题不符。

The question is about a button in a PDF file. 问题是关于PDF文件中的按钮。 When somebody clicks on this button a dialog box needs to open. 当有人单击此按钮时,需要打开一个对话框。

The answers are about buttons in a C# application. 答案与C#应用程序中的按钮有关。 There's a huge difference between a button in such an application and a button in Adobe Reader. 此类应用程序中的按钮与Adobe Reader中的按钮之间存在巨大差异。

The question can't be answered in its current phrasing because it's not clear what you want to do with the dialog box in Adobe Reader. 当前的措词无法回答该问题,因为不清楚您要使用Adobe Reader中的对话框做什么。 If you want a simple alert message, that's easy to achieve. 如果您想要一条简单的警报消息,则很容易实现。 If you expect you can create a dialog box with the same level of functionality available in a C# application, please forget the idea: you may be asking something that is completely impossible. 如果您期望可以创建一个对话框,其功能与C#应用程序中可用的功能相同,请忘记这个主意:您可能会问完全不可能的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM