Password fields match : Password Field « GUI Windows Forms « C# / CSharp Tutorial

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » GUI Windows Forms » Password Field 
23.19.2.Password fields match
Password fields match
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;

partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        if UserIsValidpassword1.Text, password2.Text ))
        {
            MessageBox.Show("Congratulations - they match!");
        }
        else
        {
            MessageBox.Show("They don't match - try again.");
        }
    }

    private bool UserIsValid(string firstPassword, string secondPassword)
    {
        return (firstPassword == secondPassword);
    }
}

partial class Form1
{
    private void InitializeComponent()
    {
        this.label1 = new System.Windows.Forms.Label();
        this.label2 = new System.Windows.Forms.Label();
        this.password1 = new System.Windows.Forms.TextBox();
        this.password2 = new System.Windows.Forms.TextBox();
        this.button1 = new System.Windows.Forms.Button();
        this.SuspendLayout();

        this.label1.AutoSize = true;
        this.label1.Location = new System.Drawing.Point(1310);
        this.label1.Name = "label1";
        this.label1.Size = new System.Drawing.Size(8314);
        this.label1.TabIndex = 0;
        this.label1.Text = "Enter password";

        this.label2.AutoSize = true;
        this.label2.Location = new System.Drawing.Point(2537);
        this.label2.Name = "label2";
        this.label2.Size = new System.Drawing.Size(7114);
        this.label2.TabIndex = 1;
        this.label2.Text = "Enter it again";

        this.password1.Location = new System.Drawing.Point(1037);
        this.password1.Name = "password1";
        this.password1.Size = new System.Drawing.Size(18220);
        this.password1.TabIndex = 2;

        this.password2.Location = new System.Drawing.Point(10334);
        this.password2.Name = "password2";
        this.password2.Size = new System.Drawing.Size(18220);
        this.password2.TabIndex = 3;

        this.button1.Location = new System.Drawing.Point(21063);
        this.button1.Name = "button1";
        this.button1.TabIndex = 4;
        this.button1.Text = "OK";
        this.button1.Click += new System.EventHandler(this.button1_Click);

        this.AutoScaleBaseSize = new System.Drawing.Size(513);
        this.ClientSize = new System.Drawing.Size(30298);
        this.Controls.Add(this.button1);
        this.Controls.Add(this.password2);
        this.Controls.Add(this.password1);
        this.Controls.Add(this.label2);
        this.Controls.Add(this.label1);
        this.Name = "Form1";
        this.Text = "Form1";
        this.ResumeLayout(false);
        this.PerformLayout();

    }

    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.Label label2;
    private System.Windows.Forms.TextBox password1;
    private System.Windows.Forms.TextBox password2;
    private System.Windows.Forms.Button button1;
}

public class PasswordFieldCompare
{
    [STAThread]
    static void Main()
    {
        Application.Run(new Form1());
    }
}
23.19.Password Field
23.19.1.Password fieldPassword field
23.19.2.Password fields matchPassword fields match
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.