Dialog Form

changing form title

Page 1 of 1

0 Replies - 1948 Views - Last Post: 11 April 2008 - 01:31 PM Rate Topic: -----

#1 r10lover10  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 26-November 07

Dialog Form

Posted 11 April 2008 - 01:31 PM

I created a dialog form that is able to change the form title to characters that were input in the textbox. But i couldn't figure out the next step which is evaluateing the input in the textbox. Any characrter will apply and the form title will be rename accordingly. No changes will be made to the form title when user keys in space bar that contains no character. The form will remain the title as the previous one if only space bars were tap.

here's my code, they are in 2 forms

form1:
#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 btnNewCaption As System.Windows.Forms.Button
	<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
		Me.btnNewCaption = New System.Windows.Forms.Button
		Me.SuspendLayout()
		'
		'btnNewCaption
		'
		Me.btnNewCaption.Location = New System.Drawing.Point(98, 121)
		Me.btnNewCaption.Name = "btnNewCaption"
		Me.btnNewCaption.Size = New System.Drawing.Size(96, 24)
		Me.btnNewCaption.TabIndex = 0
		Me.btnNewCaption.Text = "New Caption"
		'
		'Form1
		'
		Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
		Me.ClientSize = New System.Drawing.Size(292, 266)
		Me.Controls.Add(Me.btnNewCaption)
		Me.Name = "Form1"
		Me.Text = "Form1"
		Me.ResumeLayout(False)

	End Sub

#End Region

	Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

	End Sub

	Private Sub btnNewCaption_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewCaption.Click
		Dim frmCaption As New Form2
		frmCaption.ShowDialog(Me)
		If frmCaption.DialogResult = DialogResult.OK Then
			Me.Text = frmCaption.txtNewCaption.Text
		End If

	End Sub
End Class



form2:
#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 btnOK As System.Windows.Forms.Button
	Friend WithEvents btnCancel As System.Windows.Forms.Button
	Friend WithEvents txtNewCaption As System.Windows.Forms.TextBox
	<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
		Me.btnOK = New System.Windows.Forms.Button
		Me.btnCancel = New System.Windows.Forms.Button
		Me.txtNewCaption = New System.Windows.Forms.TextBox
		Me.SuspendLayout()
		'
		'btnOK
		'
		Me.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK
		Me.btnOK.Location = New System.Drawing.Point(53, 122)
		Me.btnOK.Name = "btnOK"
		Me.btnOK.TabIndex = 0
		Me.btnOK.Text = "OK"
		'
		'btnCancel
		'
		Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
		Me.btnCancel.Location = New System.Drawing.Point(165, 122)
		Me.btnCancel.Name = "btnCancel"
		Me.btnCancel.TabIndex = 1
		Me.btnCancel.Text = "Cancel"
		'
		'txtNewCaption
		'
		Me.txtNewCaption.Location = New System.Drawing.Point(82, 80)
		Me.txtNewCaption.Name = "txtNewCaption"
		Me.txtNewCaption.Size = New System.Drawing.Size(128, 20)
		Me.txtNewCaption.TabIndex = 2
		Me.txtNewCaption.Text = ""
		'
		'Form2
		'
		Me.AcceptButton = Me.btnOK
		Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
		Me.CancelButton = Me.btnCancel
		Me.ClientSize = New System.Drawing.Size(292, 266)
		Me.ControlBox = False
		Me.Controls.Add(Me.txtNewCaption)
		Me.Controls.Add(Me.btnCancel)
		Me.Controls.Add(Me.btnOK)
		Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
		Me.Name = "Form2"
		Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
		Me.Text = "Form2"
		Me.ResumeLayout(False)

	End Sub

#End Region

	Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

	End Sub
End Class



help is appreciated.

This post has been edited by r10lover10: 11 April 2008 - 01:41 PM


Is This A Good Question/Topic? 0
  • +

Page 1 of 1