Event 2 (Mouse Event)
ဒီေန႔ ကြၽန္ေတာ္တို႔ window form application ရဲ႕ event ေတြ အေၾကာင္းပဲ ဆက္ရေအာင္။ အခုကြၽန္ေတာ္က program run လိုက္ျပီး form ေပၚမွာ mouse ေရႊ႕ရင္ အဲ့ဒီ mouse pointer ရဲ႕ location ေလးကို form ရဲ႕ caption မွာ ျပခ်င္တယ္ဆိုပါေတာ့။ ဒါဆိုရင္ ကြၽန္ေတာ္က ဘယ္ event ကိုသံုးရမလဲ ဆိုရင္ Form ရဲ႕ Mouse Move Event ကိုသံုးရပါမယ္။
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
this.Text = e.Location.ToString();
}
ကြၽန္ေတာ္က form Title bar မွာ မျပခ်င္ဘူး mouse pointer ေလးရဲ႕ ေဘးမွာ ပဲ location ေလးကို ေပၚေနေစခ်င္တယ္ဆိုရင္ေတာ့ Form ေပၚမွာ စာသားေတြ ျပဖို႔အတြက္ Label Control ကိုသံုးျပီး အခုလိုေရးရပါမယ္။

pic1
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
label1.Left = e.X + 10;
label1.Top = e.Y - 10;
label1.Text = e.Location.ToString();
}
အရင္ဆံုး Form ေပၚမွာ Label တစ္ခုထည့္ရပါမယ္။ Mouse Move event မွာ အဲ့ဒီ Label ေလးရဲ႕ Location ကိုေရႊဖို႔အတြက္ Left နဲ႔ Top ကို mouse pointer လက္ရွိေရာက္ေနတဲ႔ location(x,y) သြားထည့္ေပးလိုက္ပါတယ္။ ဒီေနရာမွာ တစ္ခါတည္း သိလိုက္ဖို႔လိုတာက form ေပၚမွာ control ေတြ ေနရာေရႊ႕ခ်င္ရင္ အဲ့ဒီ control ရဲ႕ left နဲ႔ top ကို ေျပာင္းျခင္းအားျဖင့္ ေရႊ႕နိုင္တယ္ဆိုတာေလးပါ။