登录
首页 » 其他 » Visual C# 使用键盘控制窗体的移动

Visual C# 使用键盘控制窗体的移动

于 2022-03-13 发布 文件大小:223.74 kB
0 202
下载积分: 2 下载次数: 1

代码说明:

Visual C#使用键盘控制窗体的移动,创建窗体对象,设置窗体接收按键事件,定义一个标识窗体的变量,判断按键类型,判断后关闭本窗体。   private void Form1_Load(object sender, EventArgs e)   {    Frm_Main form1 = new Frm_Main();//创建窗体对象    form1.KeyPreview = true;//设置窗体接收按键事件   }   private void Form1_KeyDown(object sender, KeyEventArgs e)   {    Point point = this.Location;//定义一个标识窗体的变量    switch (e.KeyData)//判断按键类型    {    case Keys.Up://当按键为上方向键时    point.Y -= 2;    break;    case Keys.Down://当按键为下方向键时    point.Y += 2;    break;    case Keys.Right://当按键为右方向键时    point.X += 2;    break;    case Keys.Left://当按键为左方向键时    point.X -= 2;    break;    case Keys.Escape://当按键为Esc键时    this.Close();//关闭本窗体    break;    default: break;    }    this.Location = point;   }

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • Clock 桌面时钟 日历 阴历 看到的delphi程序 转发
    Clock 桌面时钟 日历 阴历 看到的delphi程序 转发-Clock desktop calendar lunar calendar clock see delphi process forward
    2022-12-18 21:15:03下载
    积分:1
  • VC语言编写的动态内存,有所不足请P我
    VC语言编写的动态内存,有所不足请P我-VC language of dynamic memory, has been less than requested P I ..............
    2022-07-01 14:47:56下载
    积分:1
  • ATMega8 voltmeter AVR working in ADC
    ATMega8 voltmeter AVR working in ADC
    2023-04-18 21:30:04下载
    积分:1
  • procedures purpose : to bring in a maze of arbitrary size, with a stack get out...
    程序目的: 输入一个任意大小的迷宫,用栈求出一条走出迷宫的路径,并 显示在屏幕上。 程序实现: 可以实现载入迷宫和保存迷宫,附带文件中有4个测试迷宫路径的 文件test1~4.dd。请将这些文件拷贝到TC当前目录下,或者在载 入时写明完全路径。由于屏幕大小的限制,当用户自己输入迷宫 时一定要注意:迷宫大小是有限制的,不小于4*3,不大于30*20。 否则会出现错误信息。输入开始时全是墙,用上下左右键移动, 用Del键删除墙,形成通路,用Enter键添加墙。输入结束时可以 将迷宫保存下来,以dd为扩展名。输入完毕时用F9键来得到结果, 找到路径时,屏幕下方会出现Path found,否则出现Path not found。 程序经Turbo C 2.0编译调试成功。运行时不用添加任何运行库。 不可以在VC上编译。-procedures purpose : to bring in a maze of arbitrary size, with a stack get out of the maze of trails and on the screen. Program : can achieve and preserve the printed maze maze, the accompanying documents were four test maze of trails to document test1 4.dd. I would be grateful if those files are copied to the TC current directory, or in the state when fully contained path. Due to restrictions on the size of the screen when the user input labyrinth must pay attention to : the size of the maze is a restriction, not less than 4* 3, not more than 30* 20. Otherwise there will be a wrong message. At the beginning of the importation of a
    2022-07-05 03:20:50下载
    积分:1
  • C#+ASP.NET,利用SMTP发送电子邮件
    C#+ASP.NET,利用SMTP发送电子邮件-C#+ ASP.NET, the use of SMTP e-mail
    2022-01-21 23:27:28下载
    积分:1
  • C + + 的游戏数独
    Các chương trình về 游戏信 gồm mà nguồn 点饮料 Cpp,CSharp,节 Cái này 点饮料 sưu tập...thấy tốt nên 共享
    2022-03-05 18:56:15下载
    积分:1
  • 一个各子棋的游戏代码,希望大家非常非常喜欢
    一个各子棋的游戏代码,希望大家非常非常喜欢-the son of a chess game code, we hope very, very like
    2022-03-14 21:52:35下载
    积分:1
  • Kelushikaer algorithm, for the shortest path
    克鲁斯卡尔算法,求最短路径-Kelushikaer algorithm, for the shortest path
    2023-06-09 07:30:03下载
    积分:1
  • 软件介绍:国内最完善功能最齐全的多级会员程序.主要功能涵盖所有多级会员管理所需,超强大会员自定义编辑功能...
    软件介绍:国内最完善功能最齐全的多级会员程序.主要功能涵盖所有多级会员管理所需,超强大会员自定义编辑功能-software introduced : the most sophisticated capabilities of the most complete multi-level membership procedures. The main function covers all multi-level members required for the management, super large members from the definition editing
    2022-06-16 08:44:38下载
    积分:1
  • dsp related information
    dsp 有关的重要资料-dsp related information
    2022-02-21 23:16:36下载
    积分:1
  • 696516资源总数
  • 106914会员总数
  • 0今日下载