- Trên Windows 7 64bit: C:\windows\syswow64\macromed\flash
SilentAutoUpdateEnable=1
ProtectedMode=0
Nguồn sưu tầm
bool shouldPaint = false;/*Tạo 1 biến so sánh Bool để sử dụng khi vẽ*/
public PainterForm()
{
InitializeComponent();
}
private void PainterForm_MouseDown( object sender, MouseEventArgs e )/*Sử dụng khi Click Mouse xuống*/
{
shouldPaint = true;/*Biến gán Giá Trị True để vẽ*/
}
private void PainterForm_MouseUp( object sender, MouseEventArgs e )/*Sử dụng khi thả chuột ra MouseUp*/
{
shouldPaint = false;
}
private void PainterForm_MouseMove( object sender, MouseEventArgs e )
{/*Constructor để vẽ đây*/
if ( shouldPaint ) /Kiểm tra biến xem true hay false nếu true thì chạy tiếp/
{
Graphics graphics = CreateGraphics();/*Khởi tạo hàm đồ họa Graphics */
graphics.FillEllipse(
new SolidBrush( Color.BlueViolet ), e.X, e.Y, 10, 10 );
/*không chắc lắm vì TA quá kém nhưng tương tự như vẽ(Cách vẽ,Tọa độ X,Tọa độ Y,Width,height): vẽ một vòng tròn, nơi con trỏ chuột có mặt*/
graphics.Dispose();/**/
}
}
/*OpenDialog đãcó ở bài trước giờ ko nói rõ những properties,event của OpenDialog nữa/
string t;
OpenFileDialog open = new OpenFileDialog();
open.FileName = "";
open.InitialDirectory = @"C:";
open.Title = "Nhap danh Sach";
open.Filter = "Text Files|*.txt|Word Documents|*.doc";
if (open.ShowDialog() == DialogResult.OK)
{
t = open.FileName;
richTextBox1.LoadFile(t, RichTextBoxStreamType.RichText);
}
textBox1.Enabled = true;
textBox2.Enabled = true;
{
i = Convert.ToInt32(amarray[d].Length);/*Điếm số ký tự có trong dòng*/
f = Convert.ToInt32(amarray[d + 1].Length);
a = amarray[d].Substring(17, i - 17);/*SubString(Ký Tự bắt đầu cắt,độ dài chuỗi cần cắt)*/
ms = amarray[d + 1].Substring(19, f - 19);
if (textBox1.Text == a && textBox2.Text == ms)/*Kiểm tra Account và Pass*/
{
for (int w = d; w < d + 6; w++)
{
s += amarray[w] + "\n";
}
MessageBox.Show(s, "Thong Tin Khac hang");
}
d += 6;/*tăng dòng kiểm tra lên đến người tiếp theo*/
}
if (textBox1.Text.Length == 0)
{
MessageBox.Show("Chua Nhap ten","Error");
textBox1.Focus();
goto t;
}
if (textBox2.Text.Length == 0)
{
MessageBox.Show("Chua Nhap Ma So","Error");
goto tt;
}
if (textBox1.Text != a || textBox2.Text != ms)
{
MessageBox.Show("Ten Hoac Ma so sai xin nhap lai", "Error");
textBox1.Focus();
}
t:{};
}
static void Main()Show Form
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());/* Chỉ Cần đổi tên là Form Khác sẽ được Load lên*/
}
Form1 f1= new Form1();+ Show 1 Form mà xem coi Form đó có Load chưa và nếu chưa exit thì hiện Form đó lên
f1.Show();
Form f1=Application.OpenForm[Form1];Hide Form
if(f1==null)
f1=new Form1();
f1.show();
this.Hide();/*Hide cái form đang xét/Exit Program
f1.Hide();/** hide form khởi tạo lúc nãy/
DialogResult r;Form Exit
r = MessageBox.Show("Do you really want to close","Ex1",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1);
if (r == DialogResult.No)
e.Cancel = true;
Timer
errorProvider
Control ctr=(Control)sender;/* tạo biến Control để sử dụng cho hết các object khác*/MenuTrip and ContextMenuTrip
if (ctr.Text.Length>0&& Char.IsDigit(ctr.Text[ctr.Text.Length - 1]))
errorProvider1.SetError(ctr,"nhan so");/*nếu sai thì hiện lỗi kiểm tra từng từ nhập vào */
else
{
errorProvider1.Clear();
}
/*Note : Char.IsDigit(ctr.Text[ctr.Text.Length - 1]): ký tự nhập vào Không là số
ctr.Text.Length>0 ctr.text.Trim()=="" : Chuỗi ko được rỗng
Char.IsDigit(e.KeyChar) --> kiểm tra xem phím vừa nhập vào textbox có phải là ký tự số hay không, hàm này trả về kiểu bool
Char.IsContro(e.KeyChar) --> kiểm tra xem phím vừa nhập vào textbox có phải là các ký tự điều khiển (các phím mũi tên,Delete,Insert,backspace,space bar) hay không, mục đích dùng hàm này là để cho phép người dùng xóa số trong trường hợp nhập sai.*/
Note:
textBox1.ForeColor = Color.Red;/*forecolor: đổi màu text còn backcolor đổi màu hết textbox*/+ Thay đổi Font
FontFamily f = new FontFamily("Times New Roman");/*Khởi tạo font mới*/+ Thay đổi Style(Định Dạng)
textBox1.Font = new Font(f,textBox1.Font.Size);/* Gnas forn mới cho font cần đổi*/
/*Note: Đánh tên Font Phải đánh cho chính xác*/
textBox1.Font = new Font(textBox1.Font,textBox1.Font.Style^FontStyle.Bold);/*Gán Style mới cho font cần gán*/Thay Đổi tùy Chọn

if (fontDialog1.ShowDialog() == DialogResult.OK)+ Color
textBox1.Font = fontDialog1.Font;/*khởi đọng Fontdialog và thay đổi Font mới*/
if (colorDialog1.ShowDialog() == DialogResult.OK)
textBox1.ForeColor = colorDialog1.Color;/*Khởi tạo colordialog và thay đổi color mới */
private void button1_Click(object sender, EventArgs e)Form 2 : Form nhập Giá trị Và truyền sang Form 1
{
Form2 f2 = new Form2();/*Tạo Form 2 mới*/
f2.value = new Form2.Getstring(Getvalue);/*gán Giá Trị Từ Methol value cua form 2 sang getvalue cua form 1 */
f2.Show();/*Hiện Form 2*/
}
public void Getvalue(string s)
{
textBox1.Text = s;/*Gán Giá Trí chuỗi S(nhận giá trị từ bên form 2)vào textBox1*/
}
public delegate void Getstring ;/*Tạo Thư viện Getstring trong delegate */
public Getstring value;/*Tạo Methol Value Trong Thư Viện mới tạo Getstring*/
if (value != null)/*Điều kiện để Gán Giá Trị*/Note: public delegate void Getstring(string ten) ta có thể nhập nhiều giá trị cho thư viện Getstring như sau public delegate void Getstring(string ten,string d,int 5,.....)
value(textBox1.Text);/*Gán giá trị*/

save.FileName = ".doc";/*tên File Cần lưu*/
save.Title = "Save văn bản";/*Tiêu đề cho giao diện save*/
save.InitialDirectory = "C:";/*Địa chỉ save*/
save.Filter = "Doc Document |.* doc";/*Gốc để save file*/
if (save.ShowDialog() == DialogResult.OK)
{
richTextBox1.SaveFile(save.FileName);
}
string s = "";
openFile.InitialDirectory = "C:";// tạo đường dẫn cho Open
openFile.Title = "Open a Text File";// Tiêu đề cho giao diện
openFile.FileName = "";//Tên file
openFile.Filter = "Text Files|*.txt|Word Documents|*.doc";// Chỉ định gốc của file cần mở
DialogResult a = openFile.ShowDialog();//Gán Ofject open cho 1 biến DialogResult
if (a == DialogResult.OK)// nếu chọn ok thì nở file
{
s = openFile.FileName;
richTextBox1.LoadFile(s, RichTextBoxStreamType.PlainText);/* Mở file văn bản nhập vào Richtexbox */
}


openFile.InitialDirectory = "C:";// tạo đường dẫn cho Open
openFile.Title = "Open a Text File";// Tiêu đề cho giao diện
openFile.FileName = "";//Tên file
openFile.Filter = "JPEG Images | *.jpg";// Chỉ định gốc của file cần mở
DialogResult a = openFile.ShowDialog();//Gán Ofject open cho 1 biến DialogResult
if(a==DialogResult.OK)
{
pictureBox1.Image =Image.FromFile(openFile.FileName);
}