Zum Inhalt springen

C# Eingabemaske Benutzername und Password


Empfohlene Beiträge

Geschrieben

Hallo zusammen,

ich möchte eine Eingabemaske erstellen mit Benutzername und Password (Password soll als * dargestellt werden), für den Anfang soll es 2 Benutzer TEST 1 und TEST 2 geben, mit den Password user 1 und user 2. Wenn der Benutzer oder das Password nicht existiert, dann soll eine Hinweismeldung kommen. Ich haben schon einiges an Quellcode zusammenbekommen , aber ich komme nicht weiter.

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

namespace WindowsFormsApplication1

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void Form1_Load(object sender, EventArgs e)

{

}

private void label1_Click(object sender, EventArgs e)

{

MessageBox.Show("Benutername oder Password falsch","Eingabefehler");

}

private void textBox2_TextChanged(object sender, EventArgs e)

{

textBox2.PasswordChar = '*';

}

}

}

namespace WindowsFormsApplication1

{

partial class Form1

{

/// <summary>

/// Erforderliche Designervariable.

/// </summary>

private System.ComponentModel.IContainer components = null;

/// <summary>

/// Verwendete Ressourcen bereinigen.

/// </summary>

/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>

protected override void Dispose(bool disposing)

{

if (disposing && (components != null))

{

components.Dispose();

}

base.Dispose(disposing);

}

#region Vom Windows Form-Designer generierter Code

/// <summary>

/// Erforderliche Methode für die Designerunterstützung.

/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.

/// </summary>

private void InitializeComponent()

{

this.button1 = new System.Windows.Forms.Button();

this.label1 = new System.Windows.Forms.Label();

this.label2 = new System.Windows.Forms.Label();

this.textBox1 = new System.Windows.Forms.TextBox();

this.textBox2 = new System.Windows.Forms.TextBox();

this.SuspendLayout();

//

// button1 Anmeldung

//

this.button1.Location = new System.Drawing.Point(337, 118);

this.button1.Name = "button1";

this.button1.Size = new System.Drawing.Size(75, 23);

this.button1.TabIndex = 0;

this.button1.Text = "Anmeldung";

this.button1.UseVisualStyleBackColor = true;

//

// label1 Benutzername

//

this.label1.AutoSize = true;

this.label1.Location = new System.Drawing.Point(54, 40);

this.label1.Name = "label1";

this.label1.Size = new System.Drawing.Size(75, 13);

this.label1.TabIndex = 1;

this.label1.Text = "Benutzername";

this.label1.Click += new System.EventHandler(this.label1_Click);

//

// label2

//

this.label2.AutoSize = true;

this.label2.Location = new System.Drawing.Point(54, 94);

this.label2.Name = "label2";

this.label2.Size = new System.Drawing.Size(53, 13);

this.label2.TabIndex = 2;

this.label2.Text = "Password";

//

// textBox1

//

this.textBox1.Location = new System.Drawing.Point(171, 40);

this.textBox1.Name = "textBox1";

this.textBox1.Size = new System.Drawing.Size(241, 20);

this.textBox1.TabIndex = 3;

//

// textBox2

//

this.textBox2.Location = new System.Drawing.Point(171, 87);

this.textBox2.Name = "textBox2";

this.textBox2.Size = new System.Drawing.Size(241, 20);

this.textBox2.TabIndex = 4;

this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged);

//

// Form1

//

this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

this.ClientSize = new System.Drawing.Size(452, 153);

this.Controls.Add(this.textBox2);

this.Controls.Add(this.textBox1);

this.Controls.Add(this.label2);

this.Controls.Add(this.label1);

this.Controls.Add(this.button1);

this.Name = "Form1";

this.Text = "Dienstplan";

this.Load += new System.EventHandler(this.Form1_Load);

this.ResumeLayout(false);

this.PerformLayout();

}

#endregion

private System.Windows.Forms.Button button1;

private System.Windows.Forms.Label label1;

private System.Windows.Forms.Label label2;

private System.Windows.Forms.TextBox textBox1;

private System.Windows.Forms.TextBox textBox2;

}

}

Danke im Voraus.

Geschrieben

Hallo vocki72,

zum einen möchte ich dir empfehlen den

 Tag zu benutzen um Quellcode besser im Forum darstellen zu können. 

Mit einer Klasse für die Benutzer und einer IF-Verzweigung ist dein Problem schnell gelöst. Ich möchte dir empfehlen dich mit den Grundlagen der Programmierung und von C# auseinander zu setzten. ;-)

textBoxen haben bei C# eine Eigenschaft PasswordChar. Wenn du die Eigenschaft auf * setzt werden die Zeichen dierekt als * angezeigt.

Hier noch ein Link zu einem Kostenlosen C# Buch.

http://openbook.galileocomputing.de/visual_csharp_2012/

Erstelle ein Benutzerkonto oder melde Dich an, um zu kommentieren

Du musst ein Benutzerkonto haben, um einen Kommentar verfassen zu können

Benutzerkonto erstellen

Neues Benutzerkonto für unsere Community erstellen. Es ist einfach!

Neues Benutzerkonto erstellen

Anmelden

Du hast bereits ein Benutzerkonto? Melde Dich hier an.

Jetzt anmelden

Fachinformatiker.de, 2024 by SE Internet Services

fidelogo_small.png

Schicke uns eine Nachricht!

Fachinformatiker.de ist die größte IT-Community
rund um Ausbildung, Job, Weiterbildung für IT-Fachkräfte.

Fachinformatiker.de App

Download on the App Store
Get it on Google Play

Kontakt

Hier werben?
Oder sende eine E-Mail an

Social media u. feeds

Jobboard für Fachinformatiker und IT-Fachkräfte

×
×
  • Neu erstellen...