1. open Microsoft Visual Studio newly build C# Windows Forms Application , Named login


2. Modify the Text attribute , add controls Label,TextEdit(ps: Pay attention to the settings Name Adjustment of attributes and positions ), Then add the control SimpleButton(ps: The image in front of the control passes through Image Property settings ), The effect is as follows :

3. Add a class to the project , Named DemoCls, The code is as follows :
using System; using System.Collections.Generic; using System.Linq; using
System.Text;using System.Threading.Tasks; namespace login { class DemoCls {
public string sqlSelect() { return "OK"; } } }
4. Add click events determined by button , Add user and password TextEdit Of KeyDown event , The code is as follows (ps: The database is set according to its own local database ):
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; using
System.Data.SqlClient; namespace login {public partial class Form1 : Form {
public Form1() { InitializeComponent(); } private void btnOK_Click(object
sender, EventArgs e) {string conn = "server=.;database= Database name ;user id =
user name ;password= password "; SqlConnection con = new SqlConnection(conn); con.Open();
SqlDataAdapter sqlDa =new SqlDataAdapter("select * from tb_stu", con);
DataTable dt =new DataTable(); sqlDa.Fill(dt); MessageBox.Show(dt.Rows[0][1
].ToString());// Call class DemoCls Medium sqlSelect method DemoCls my1 = new DemoCls();
MessageBox.Show(my1.sqlSelect()); }// When the user has finished inputting information in the first text box, press Enter Key to automatically focus on the password input box private
void txtUser_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode ==
Keys.Enter) { txtPWD.Focus(); } }// When the user has finished inputting information in the second text box, press Enter The bond is equivalent to click confirm button private
void txtPWD_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode ==
Keys.Enter) { btnOK_Click(sender,null); } } } }

Technology
©2020 ioDraw All rights reserved
Interview questions : Handwritten list ( Include reverse linked list )C Notes on language learning —— Pointer : Pointer and one dimensional array error: (-215:Assertion failed) Solution layui.table Examples of dynamically getting header and list data python Simple record of network programming After the outbreak Which programming has a bright future Java Summary of basic learning (162)—— How to ensure thread safety ?vue el-input Do not enter special characters Only numbers can be entered Regular verification MYSQL database DML Common commands python in list and str Mutual conversion