調用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 按鍵行動控制項