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); } } } }

©2020 ioDraw All rights reserved
Vue The difference between single page and multi page 0.96OLED display -4 Line SPI explain R In language Axis() Detailed explanation of function parameters JAVA Snake games ( Source code + notes )C++ vector Simulation Implementation of class javascript Adding and deleting form information CCF A series of questions --2016 year 4 Month 1 Calculation of break point postman Interface test get timestamp and MD5 encryption 【 Recommended benefits 】c++ use easyx Making pixel birds , Simple hands on games TCP/IP There are so many loopholes in the agreement ?