Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>No.<br> You'll have to make a custom form with <code>FormBorderType = FixedDialog</code>.<br> Here is a little tutorial:</p> <h1>Creating Dialog Boxes in .NET</h1> <p><strong>by James D. Murray on Jun.12, 2007, under 70-526</strong></p> <p><em>Microsoft Certification Exam: 70-526 (MCTS)<br> Objective: Create and use custom dialog boxes in Windows Forms applications.<br> Language: Visual Basic 2005 (click here for the C# version of this entry)</em></p> <p>I remember the first time I needed to create a dialog box in a .NET application that I was writing in C#. Being a long-time Visual Basic programmer, I assumed that this could easily be accomplished by using a dialog box template included with Visual Studio.NET. To my surprise, no such form template existed for C#, although one does for Visual Basic 2005. After wading through several books and Web pages filled with information on Windows Forms 2.0 programming, a basic set of steps became apparent to me for manually converting a .NET form into a Windows dialog box:</p> <p>Step 1 : Add a Form to your .NET project and name it “DialogBoxForm”.</p> <p>Step 2 : Drop two buttons in the lower right-hand area of the Form and name them “OKButton” and “CancelButton”.</p> <p>Step 3 : Change the following properties of the Form to adjust its appearance and behavior to be like a standard dialog box:</p> <pre> Property Value Description ----------------------------------------------------------------------------------------------------------------------------- AcceptButton OK button instance Causes form to return value DialogResult.OK. Only used on modal dialog boxes. CancelButton Cancel button instance Causes form to return value DialogResult.Cancel. Only used on modal dialog boxes. FormBorderStyle FixedDialog Create a non-sizable form with no control box on the title bar. HelpButton True The Help button appears in the caption bar next to the Close button. The ControlBox property must be True for these buttons to be visible. MaximizeBox False Hide the Maximize button in the title bar. MinimizeBox False Hide the Minimize button in the title bar. ShowIcon False The title bar icon is not visible in a dialog box. ShowInTaskBar False Do not indicate the presence of the form on the Windows Task Bar. Start Position CenterParent The initial position of a dialog box is over its parent form. Size As Needed The fixed size needed for the dialog box. </pre> <p>These properties can be set using the Properties window for the form, or using code placed in the Form’s Load event:</p> <pre><code> Me.AcceptButton = OKButton Me.CancelButton = CancelButton Me.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedDialog Me.HelpButton = True Me.MaximizeBox = False Me.MinimizeBox = False Me.ShowInTaskbar = False Me.ShowIcon = False Me.StartPosition = FormStartPosition.CenterParent </code></pre> <p>Step 4 : Add the following button click event handlers to the Form:</p> <pre> Private Sub OKButton_Click(ByVal sender As Object, _ByVal e As EventArgs) ' User clicked the OK button Me.DialogResult = Windows.Forms.DialogResult.OK End Sub Private Sub CancelButton_Click(ByVal sender As Object, _ByVal e As EventArgs) ' User clicked the Cancel button Me.DialogResult = Windows.Forms.DialogResult.Cancel End Sub </pre> <p>Step 5 : Add properties that you need to move data into and out of the dialog box as you would for any Form:</p> <pre> Private _LoginName As String Private _LoginPassword As String Public Property LoginName() As String Get Return _LoginName End Get Set(ByVal value As String) _LoginName = value End Set End Property Public Property LoginPassword() As String Get Return _LoginPassword End Get Set(ByVal value As String) _LoginPassword = value End Set End Property </pre> <p>Step 6 : Show the dialog box modally by calling the ShowDialog() of the form:</p> <pre> Public Sub ShowDialogBox() Dim dialog As New DialogBoxForm dialog.LoginName = "JDMurray" dialog.LoginPassword = String.Empty If dialog.ShowDialog() = Windows.Forms.DialogResult.OK Then Debug.WriteLine("Login Name: " & dialog.LoginName) Debug.WriteLine("Password: " & dialog.LoginPassword) Else ' User clicked the Cancel button End If End Sub </pre> <p>Step 7 : To show the dialog box modelessly, call the Show() method of DialogBoxForm instead. You will need to add an event handler to the Close event of DialogBoxForm to know when the user closes the dialog box:</p> <pre> Public Sub ShowDialogBox() Dim dialog As DialogBoxForm = New DialogBoxForm dialog.LoginName = "JDMurray" dialog.Password = String.Empty AddHandler dialog.FormClosed, AddressOf dialog_FormClosed dialog.Show() ' The Show() method returns immediately End Sub Private Sub dialog_FormClosed(ByVal sender As Object, _ ByVal e As FormClosedEventArgs) ' This method is called when the user closes the dialog box End Sub </pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload