win form html,HtmlWindow.Confirm(String) 方法 (System.Windows.Forms) | Microsoft Docs

顯示對話方塊,其中包含請求是/否回應的訊息和按鈕。Displays a dialog box with a message and buttons to solicit a yes/no response.

public:

bool Confirm(System::String ^ message);

public bool Confirm (string message);

member this.Confirm : string -> bool

Public Function Confirm (message As String) As Boolean

參數

message

要顯示給使用者的文字。The text to display to the user.

傳回

如果使用者按下 [是],則為 true;如果使用者按下 [否] 或關閉對話方塊,則為 false。true if the user clicked Yes; false if the user clicked No or closed the dialog box.

範例

複製下列 HTML,並將其儲存至名為 orderForm.htm 的表單:Copy the following HTML and save it into a form called orderForm.htm:

Select Part Type:

AZ-3700

AZ-3701

AZ-3702

Quantity:

Building/Desk:

/

下列範例會在 Confirm 使用者提交時顯示對話方塊 NewOrderForm 。The following example displays a Confirm dialog box when the user submits NewOrderForm.

HtmlWindow orderWindow;

HtmlElement formElement;

private void LoadOrderForm()

{

if (!(webBrowser1.Document == null))

{

HtmlDocument doc = webBrowser1.Document;

orderWindow = doc.Window.OpenNew(new Uri("file://C:\\orderForm.htm"), "");

//!TODO: Perform this in the load event handler!

// Get order form.

HtmlElementCollection elemCollection = doc.All.GetElementsByName("NewOrderForm");

if (elemCollection.Count == 1)

{

formElement = elemCollection[0];

//!TODO: Awaiting DCR

//formElement.AttachEventHandler("onsubmit", new HtmlElementEventHandler(Form_Submit));

}

}

}

private void Form_Submit(object sender, HtmlElementEventArgs e)

{

bool doOrder = orderWindow.Confirm("Once you transmit this order, you cannot cancel it. Submit?");

if (!doOrder)

{

//Cancel the submit.

e.ReturnValue = false;

orderWindow.Alert("Submit cancelled.");

}

}Dim OrderWindow As HtmlWindow

Dim FormElement As HtmlElement

Private Sub NewOrderButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewOrderButton.Click

LoadOrderForm()

End Sub

Private Sub LoadOrderForm()

If (WebBrowser1.Document IsNot Nothing) Then

With WebBrowser1.Document

OrderWindow = .Window.OpenNew(New Uri("file://C:\\orderForm.htm"), "")

' !TODO: Perform this in the load event handler!

' Get order form.

Dim ElemCollection As System.Windows.Forms.HtmlElementCollection = .All.GetElementsByName("NewOrderForm")

If (ElemCollection.Count = 1) Then

FormElement = ElemCollection(0)

' TODO: Resolve this.

'FormElement.AttachEventHandler("onsubmit", New HtmlElementEventHandler(AddressOf Form_Submit))

End If

End With

End If

End Sub

Private Sub Form_Submit(ByVal sender As Object, ByVal e As HtmlElementEventArgs)

Dim DoOrder As Boolean = OrderWindow.Confirm("Once you transmit this order, you cannot cancel it. Submit?")

If (Not DoOrder) Then

' Cancel the submit.

e.ReturnValue = False

OrderWindow.Alert("Submit cancelled.")

End If

End Sub

備註

Confirm 顯示模式對話方塊;使用者將無法存取基礎的 HTML 網頁,而不需要先關閉此對話方塊。Confirm displays a modal dialog box; the user will not be able to access the underlying HTML page without first closing this dialog box.

適用於

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值