)c# winform 鍵盤按鍵控制操作行動控制項,linkLabel,擷取按索引值,一個俄羅斯方塊源碼

來源:互聯網
上載者:User

調用start方法啟動一個預設的Internet瀏覽器

System.Diagnostics.Process.Start("http://www.baidu.com"); 

Form1  按鍵行動控制項

C#代碼
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace man100{public partial class Form1 : Form{public Form1(){InitializeComponent();}public static int buChang = 5; private void Form1_KeyDown(object sender, KeyEventArgs e){//MessageBox.Show(e.KeyValue.ToString());//用來找按鍵int值//MessageBox.Show(e.KeyCode.ToString());//用來找按鍵英文值if (e.KeyCode.ToString().Equals("Left"))//左{//MessageBox.Show("左");//label1.Location = new Point(0,0);int x_ZuoBiao = label1.Location.X;int y_ZuoBiao = label1.Location.Y;if (label1.Location.X < 15){label1.Location = new Point(x_ZuoBiao, y_ZuoBiao);return;}label1.Location = new Point(x_ZuoBiao - buChang, y_ZuoBiao);}else if (e.KeyCode.ToString().Equals("Up"))//上{//MessageBox.Show("上");int x_ZuoBiao = label1.Location.X;int y_ZuoBiao = label1.Location.Y;if (label1.Location.Y < 15){label1.Location = new Point(x_ZuoBiao, y_ZuoBiao);return;}label1.Location = new Point(x_ZuoBiao, y_ZuoBiao - buChang);}else if (e.KeyCode.ToString().Equals("Right"))//右{//MessageBox.Show("右");int x_ZuoBiao = label1.Location.X;int y_ZuoBiao = label1.Location.Y;if (label1.Location.X > 265){label1.Location = new Point(x_ZuoBiao, y_ZuoBiao);return;}label1.Location = new Point(x_ZuoBiao + buChang, y_ZuoBiao);}else if (e.KeyCode.ToString().Equals("Down"))//下{//MessageBox.Show("下");int x_ZuoBiao = label1.Location.X;int y_ZuoBiao = label1.Location.Y;if (label1.Location.Y > 395)//超出界限就不動{label1.Location = new Point(x_ZuoBiao, y_ZuoBiao);return;}label1.Location = new Point(x_ZuoBiao, y_ZuoBiao + buChang);}}}}
Form2
linkLabel用法
C#代碼
using System;   using System.Collections.Generic;   using System.ComponentModel;   using System.Data;   using System.Drawing;   using System.Text;   using System.Windows.Forms;     namespace man100   {       public partial class Form2 : Form       {           public Form2()           {               InitializeComponent();                 this.linkLabel1.Text = "黑色頭髮 百度 Google Yahoo";               this.linkLabel1.Links.Add(0, 4, "http://www.heisetoufa.javaeye.com");//第一個參數設定底線從哪裡開始,第二個參數設定底線占幾個長度               this.linkLabel1.Links.Add(5, 2, "http://www.baidu.com");               this.linkLabel1.Links.Add(8, 6, "http://www.google.com");           }             private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)           {               this.linkLabel1.Links[linkLabel1.Links.IndexOf(e.Link)].Visited = true;               string target = e.Link.LinkData as string;               if (target != null && target.StartsWith("http://"))               {                   System.Diagnostics.Process.Start(target);               }               else              {                   MessageBox.Show("Item clicked: " + target);               }           }         }   }
轉自黑色頭髮:http://heisetoufa.javaeye.com/blog/348167源碼下載:

man100.rar (34.7 KB)

c#俄羅斯方塊源碼.rar (168 KB)

調用start方法啟動一個預設的Internet瀏覽器

System.Diagnostics.Process.Start("http://www.baidu.com"); 

Form1  按鍵行動控制項

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.