众所周知,人生是一个漫长的流程,不断克服困难,不断反思前进的过程。在这个过程中会产生很多对于人生的质疑和思考,于是我决定将自己的思考,经验和故事全部分享出来,以此寻找共鸣 !!!
专注于Android/Unity和各种游戏开发技巧,以及各种资源分享(网站、工具、素材、源码、游戏等)
有什么需要欢迎私我,交流群让学习不再孤单。



public partial class Form1 : Form
{public Form1(){InitializeComponent();}private void textBox1_Enter(object sender, EventArgs e){((TextBox) sender).BackColor = Color.CornflowerBlue;}private void textBox1_Leave(object sender, EventArgs e){((TextBox) sender).BackColor = Color.White;}private void textBox1_KeyDown(object sender, KeyEventArgs e){if (e.KeyValue == 13){int n = Convert.ToInt32(((TextBox) sender).Tag.ToString());Clear_Control(this.Controls, n, 6);}}#region 遍历指定的控件/// /// 遍历指定的控件/// /// 可视化控件/// 控件标识/// 最大标识public void Clear_Control(Control.ControlCollection Con, int n, int m){int tem_n = 0;foreach (Control C in Con){//遍历可视化组件中的所有控件if (C.GetType().Name == "TextBox") //判断是否为TextBox控件{if (n == m)tem_n = 1;elsetem_n = n + 1;if (Convert.ToInt32(((TextBox) C).Tag.ToString()) == tem_n)((TextBox) C).Focus(); //清空当前控件}}}#endregion
}
public partial class Form1 : Form
{public Form1(){InitializeComponent();}public static int Example_X = 0;public static int Example_Y = 0;public static int Example_W = 0;public static Point CPoint;#region 利用窗体上的控件移动窗体/// /// 利用控件移动窗体/// /// 窗体/// 控件的移动事件public void FrmMove(Form Frm, MouseEventArgs e) //Form或MouseEventArgs添加命名空间using System.Windows.Forms;{if (e.Button == MouseButtons.Left){Point myPosittion = Control.MousePosition; //获取当前鼠标的屏幕坐标myPosittion.Offset(CPoint.X, CPoint.Y); //重载当前鼠标的位置Frm.DesktopLocation = myPosittion; //设置当前窗体在屏幕上的位置}}#endregion#region 获取鼠标的当前位置/// /// 获取鼠标的当前位置/// /// 窗体/// 窗体上有关鼠标的一些信息public void FrmScreen_SizeInfo(Form Frm, MouseEventArgs e){if (e.Button == MouseButtons.Left){Example_X = e.X;Example_Y = e.Y;Example_W = Frm.Width;}}#endregion#region 改变窗体的大小(用于鼠标的移动事件)/// /// 改变窗体的大小(用于鼠标的移动事件)/// /// 窗体/// 设置窗体边框的控件/// 窗体上有关鼠标的一些信息public void FrmScreen_EnlargeSize(Form Frm, Panel Pan, MouseEventArgs e){if (e.Button == MouseButtons.Left){switch (Pan.Name){case "panel_Right": //如果移动的是窗体的右边框{if (this.Width <= 70) //如果窗体的宽度小于等于70{Frm.Width = 70; //设置窗体的宽度为70//如果用鼠标向右移动窗体的右边框if (Cursor.Position.X - Frm.Left + (Pan.Width - Example_X) > Frm.Width){//根据鼠标的移动值,增加窗体的宽度Frm.Width = Cursor.Position.X - Frm.Left + (Pan.Width - Example_X);}break;}//根据鼠标的移动值,增加窗体的宽度Frm.Width = Cursor.Position.X - Frm.Left + (Pan.Width - Example_X);break;}case "panel_BR": //如果移动的是窗体的右下角{//如果窗体的大小不为窗体大小的最小值if (this.Width > 70 && this.Height > (panel_Title.Height + panel_Bn.Height + 1)){//根据鼠标的移动改变窗体的大小Frm.Height = Cursor.Position.Y - Frm.Top + (Pan.Height - Example_Y);Frm.Width = Cursor.Position.X - Frm.Left + (Pan.Width - Example_X);}else{if (this.Width <= 70) //如果窗体的宽度小于等于最小值{Frm.Width = 70; //设置窗体的宽度为70if (this.Height <= (panel_Title.Height + panel_Bn.Height + 1)) //如果窗体的高小于最小值{Frm.Height = panel_Title.Height + panel_Bn.Height + 1; //设置窗体的最小高度//如果用鼠标向下移动窗体的底边框if (Cursor.Position.Y - Frm.Top + (Pan.Height - Example_Y) > Frm.Height){//根据鼠标的移动值,增加窗体的高度Frm.Height = Cursor.Position.Y - Frm.Top + (Pan.Height - Example_Y);}break;}//如果用鼠标向右移动窗体if (Cursor.Position.X - Frm.Left + (Pan.Width - Example_X) > Frm.Width){//增加窗体的宽度Frm.Width = Cursor.Position.X - Frm.Left + (Pan.Width - Example_X);}break;}if (this.Height <= (panel_Title.Height + panel_Bn.Height + 1)) //如果窗体的高度小于等于最小值{Frm.Height = panel_Title.Height + panel_Bn.Height + 1; //设置窗体的高度为最小值Frm.Width = Cursor.Position.X - Frm.Left + (Pan.Width - Example_X); //改变窗体的宽度//如果用鼠标向下移动窗体的边框if (Cursor.Position.Y - Frm.Top + (Pan.Height - Example_Y) > Frm.Height){Frm.Height = Cursor.Position.Y - Frm.Top + (Pan.Height - Example_Y); //增加窗体的高度}break;}}break;}case "panel_Bn": //如果移动的是窗体的底边框{if (this.Height <= (panel_Title.Height + panel_Bn.Height + 1)) //如果窗体的高度小于等于最小值{Frm.Height = panel_Title.Height + panel_Bn.Height + 1; //设置窗体的高度为最小值//如果用鼠标向下移动窗体的下边框if (Cursor.Position.Y - Frm.Top + (Pan.Height - Example_Y) > Frm.Height){Frm.Height = Cursor.Position.Y - Frm.Top + (Pan.Height - Example_Y); //增加窗体的高度}break;}Frm.Height = Cursor.Position.Y - Frm.Top + (Pan.Height - Example_Y); //增加窗体的高度break;}}}}#endregionprivate void panel_Right_MouseDown(object sender, MouseEventArgs e){FrmScreen_SizeInfo(this, e); //获取鼠标的当前位置}private void panel_Right_MouseMove(object sender, MouseEventArgs e){FrmScreen_EnlargeSize(this, (Panel) sender, e); //改变窗体的大小}private void pictureBox1_Click(object sender, EventArgs e){this.Close();}private void panel_TitL_MouseDown(object sender, MouseEventArgs e){int Tem_X = -e.X;if (Convert.ToInt16(((Panel) sender).Tag.ToString()) == 2) //如果移动的是标题栏的中间部分Tem_X = -e.X - panel_TitL.Width;if (Convert.ToInt16(((Panel) sender).Tag.ToString()) == 3) //如果移动的是标题栏的尾端Tem_X = -(this.Width - ((Panel) sender).Width) - e.X;CPoint = new Point(Tem_X, -e.Y);}private void panel_TitL_MouseMove(object sender, MouseEventArgs e){FrmMove(this, e);}
}
需要的再直接Call我,直接发。
📢作者:小空和小芝中的小空
📢转载说明-务必注明来源:https://zhima.blog.csdn.net/
📢这位道友请留步☁️,我观你气度不凡,谈吐间隐隐有王者霸气💚,日后定有一番大作为📝!!!旁边有点赞👍收藏🌟今日传你,点了吧,未来你成功☀️,我分文不取,若不成功⚡️,也好回来找我。
温馨提示:点击下方卡片获取更多意想不到的资源。
