Form Concepts CodeSample - Retrieving response from MessageBox
From Visual WebGui Wiki
| This article will have a few sections added to it soon, based on the following article type skeleton: NewCodeSampleTemplate |
Overview
This article is a part of Form Concepts series of articles.
The samplecode shows how you use the MessageBox and receive a response from the user by supplying a Closed event handler that will be invoked when the user closes the MessageBox.
VB.NET Code
Private Sub MyMethod() MessageBox.Show("Do you want to continue?", "Confirmation", MessageBoxButtons.YesNo, AddressOf msgBoxHandler) End Sub Private Sub msgBoxHandler(ByVal sender As Object, ByVal e As EventArgs) Dim msgForm As Form = TryCast(sender, Form) If msgForm IsNot Nothing Then If msgForm.DialogResult = Gizmox.WebGui.Forms.DialogResult.Yes Then MessageBox.Show("Yes was chosen") Else MessageBox.Show("No was chosen") End If End If End Sub
C# Code
private void MyMethod() { MessageBox.Show("Do you want to continue?", "Confirmation", MessageBoxButtons.YesNo, msgBoxHandler); } private void msgBoxHandler(object sender, EventArgs e) { Form msgForm = sender as Form; if (msgForm != null) { if (msgForm.DialogResult == Gizmox.WebGui.Forms.DialogResult.Yes) { MessageBox.Show("Yes was chosen"); } else { MessageBox.Show("No was chosen"); } } }
