Popup Control

M

Michael Turner

Hi Guys

I am in the process of developing a control, and will need it to "popup" on
the users for on the press of a button ask for some input and then chuck the
information back to the form. Does anyone know how I can develop this.

Thanks,
Mike.
 
P

Peter Proost

Check out the form.showdialog method

for example form2 is the form you want to show as input form on form1

on form1:

dim input as as new form2
if input.showdialog = dialogresult.ok then
variable = input.nameOfAPropertyOnForm2
end if

on form2 set an ok button and in the buttons click event set dialogresult =
dialogresult.ok


hth Peter
 
H

Herfried K. Wagner [MVP]

Michael Turner said:
I am in the process of developing a control, and will need it to "popup"
on
the users for on the press of a button ask for some input and then chuck
the
information back to the form. Does anyone know how I can develop this.

Add a form and use it as input window:

\\\
Dim f As New FooForm()
If f.ShowDialog() = DialogResult.OK Then
...
End If
///
 
M

Michael Turner

Hi Guys

That seems to be a new form. I am creating a control and really wanted it to
popup on form 1, is there away to do this or do i need to use a form.

Mike.
 
P

Peter Proost

Hi create a new form called input then and copy paste the code below, in the
form where you want the input box to show copy paste the other piece of code
below. I think this will do what you want

hth Peter

'copy paste on the form when you want the inputbox to show
Dim obj As New input()
If obj.ShowDialog = DialogResult.OK Then
MsgBox(obj.giveValue)
End If



'The inputbox

Public Class input
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(194, 8)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(60, 34)
Me.Button1.TabIndex = 0
Me.Button1.Text = "OK"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(6, 14)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(178, 20)
Me.TextBox1.TabIndex = 1
Me.TextBox1.Text = ""
'
'input
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(262, 59)
Me.Controls.AddRange(New System.Windows.Forms.Control()
{Me.TextBox1, Me.Button1})
Me.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedDialog
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "input"
Me.StartPosition =
System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "input"
Me.ResumeLayout(False)

End Sub

#End Region

Public ReadOnly Property giveValue() As String
Get
Return TextBox1.Text
End Get
End Property

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
DialogResult = DialogResult.OK
End Sub

End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top