sadui
Thú CƯng :
Số bài viết : 25 Điểm : 40 Được cảm ơn : 3 Ngày sinh : 15/02/1988 Tham gia ngày : 26/06/2010 Tuổi : 36 Đến từ : Pakse, Lao
| Tiêu đề: OnthiC#_3Nhom(code) 17/12/2010, 20:14 | |
| OnthiC#_3Nhom(code)
Test1_Mr.Mouse(TextBox,maskedTextBox,listBox, comboBox,button) using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
namespace WindowsFormsApplication1 { public partial class Test : Form { public Test() { InitializeComponent(); }
private void Test_Load(object sender, EventArgs e) { textBox1.Focus(); }
private void button2_Click(object sender, EventArgs e) { this.Close(); }
private void button1_Click(object sender, EventArgs e) { MessageBox.Show("OK", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox1.Text = ""; maskedTextBox1.Text = maskedTextBox2.Text = ""; comboBox1.Text = "(Select)"; listBox1.ClearSelected(); textBox1.Focus(); }
private void textBox1_Leave(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show("Làm ơn nhập Name", "Error"); textBox1.Focus(); } }
private void maskedTextBox1_Leave(object sender, EventArgs e) { if (maskedTextBox1.Text == " / /") { MessageBox.Show("Làm ơn nhập Birthday", "Error"); maskedTextBox1.Focus(); } }
private void comboBox1_Leave(object sender, EventArgs e) { if (comboBox1.Text == "(Select)") { MessageBox.Show("Làm ơn chọn Gender", "Error"); comboBox1.Focus(); } }
private void listBox1_Leave(object sender, EventArgs e) { if (listBox1.SelectedItems.Count < 1) { MessageBox.Show("Làm ơn chọn Skills", "Error"); listBox1.Focus(); } }
private void maskedTextBox2_Leave(object sender, EventArgs e) { if (maskedTextBox2.Text == " -") { MessageBox.Show("Làm ơn nhập vào Code Zip", "Error"); maskedTextBox2.Focus(); } } } } Test2_Nhom_Mr.Mouse(Panel,GroupBox,Radio button,checkedBox,checkedListBox) using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
namespace WindowsFormsApplication2 { public partial class Form1 : Form { String msg = "";
public Form1() { InitializeComponent(); }
private void button2_Click(object sender, EventArgs e) { this.Close(); }
private void button1_Click(object sender, EventArgs e) { msg = "Name: " + textBox1.Text + "\n"; if (radioButton1.Checked) { msg += "Gender: " + radioButton1.Text + "\n"; } else { msg += "Gender: " + radioButton2.Text + "\n"; } msg += "Address: " + textBox2.Text + "\n Qua:"; for (int i = 0; i < checkedListBox1.CheckedItems.Count; i++) { msg += " " + checkedListBox1.CheckedItems[i].ToString(); } msg += "\n Assests:"; if (checkBox1.Checked) msg += checkBox1.Text + "\n"; if (checkBox2.Checked) msg += checkBox2.Text + "\n"; if (checkBox3.Checked) msg += checkBox3.Text + "\n"; MessageBox.Show(msg); } } }
Test3_xe_Nhom_Mr.Mouse(PictureBox,ImageList) using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
namespace WindowsFormsApplication3 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox1.Text == "Nouvo LX") { pictureBox1.Image = imageList1.Images[0]; textBox1.Text = "Nouvo LX"; textBox2.Text = "40"; textBox3.Text = "700"; } else if (comboBox1.Text == "Sirius R") { pictureBox1.Image = imageList1.Images[1]; textBox1.Text = "Sirius"; textBox2.Text = "45"; textBox3.Text = "80"; } else if (comboBox1.Text == "Honda 72") { pictureBox1.Image = imageList1.Images[2]; textBox1.Text = "Honda 72"; textBox2.Text = "50"; textBox3.Text = "120"; } else { pictureBox1.Image = imageList1.Images[3]; textBox1.Text = "Honda 67"; textBox2.Text = "50"; textBox3.Text = "120"; } //Hond 67 } } }
Bổ xung ComboBox
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO;
namespace Test_4 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }
private void Form1_Load(object sender, EventArgs e) { DriveInfo[] driver = DriveInfo.GetDrives(); foreach (DriveInfo d in driver) // { comboBox1.Items.Add(d.Name); // Lấy hết Ổ đĩa trên máy đưa vào combobox } SetFileColumns(); //LoadFilesFromFolder(folder, searchPattern); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { listView1.Items.Clear(); // làm sạch Listviewf try { DirectoryInfo Direc = new DirectoryInfo(comboBox1.Text); DirectoryInfo[] Direcs = Direc.GetDirectories(); FileInfo[] files = Direc.GetFiles(); foreach (DirectoryInfo d in Direcs) // Load Folder { ListViewItem liv = new ListViewItem(d.Name); liv.SubItems.Add("Folder"); listView1.Items.Add(liv); liv.ImageIndex = 0; } foreach (FileInfo d in files) // Load File { ListViewItem lvi = new ListViewItem(d.Name); lvi.SubItems.Add("File"); listView1.Items.Add(lvi); listView1.SmallImageList = imageList1; lvi.ImageIndex = 1; } } catch (Exception _e) { MessageBox.Show("Error: " + _e.Message); } }
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox2.SelectedIndex == 0) { listView1.View = View.LargeIcon; } else if (comboBox2.SelectedIndex == 1) { listView1.View = View.Details; } else if (comboBox2.SelectedIndex == 2) { listView1.View = View.SmallIcon; } else if (comboBox2.SelectedIndex == 3) { listView1.View = View.List; } else { listView1.View = View.Tile; } } private void SetFileColumns() { ColumnHeader colHead;
colHead = new ColumnHeader(); colHead.Text = "Filename"; colHead.Width = this.listView1.ClientSize.Width - 250; this.listView1.Columns.Add(colHead);
colHead = new ColumnHeader(); colHead.Text = "Size"; colHead.Width = 100; this.listView1.Columns.Add(colHead); }
public void LoadFilesFromFolder(string folder, string searchPattern) { ListViewItem.ListViewSubItem lvsi;
this.listView1.Items.Clear(); // Clear all item. this.listView1.Columns.Clear(); this.SetFileColumns(); DirectoryInfo dirInfo = new DirectoryInfo(folder); FileInfo[] fileInfo = dirInfo.GetFiles(searchPattern); foreach (FileInfo fi in fileInfo) { ListViewItem lvi = new ListViewItem(); lvi.Text = fi.Name; lvi.Tag = fi.FullName; lvi.Name = fi.Name;
lvsi = new ListViewItem.ListViewSubItem(); lvsi.Text = fi.Length.ToString(); lvi.SubItems.Add(lvsi);
lvsi = new ListViewItem.ListViewSubItem(); lvsi.Text = fi.LastAccessTime.ToString(); lvi.SubItems.Add(lvsi);
this.listView1.Items.Add(lvi);
} this.listView1.View = View.Details; } } }
ListBox using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
namespace listbox_2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }
private void button4_Click(object sender, EventArgs e) { for (int i = 0; i < listBox2.Items.Count; i++) { listBox1.Items.Add(listBox2.Items[i].ToString()); } listBox2.Items.Clear(); }
private void button3_Click(object sender, EventArgs e) { for (int i = 0; i < listBox2.SelectedItems.Count; i++) { listBox1.Items.Add(listBox2.SelectedItems[i]).ToString(); listBox2.Items.Remove(listBox2.SelectedItems[i]); } }
private void button2_Click(object sender, EventArgs e) { for (int i = 0; i < listBox1.SelectedItems.Count; i++) { listBox2.Items.Add(listBox1.SelectedItems[i]).ToString(); listBox1.Items.Remove(listBox1.SelectedItems[i]); } }
private void button1_Click(object sender, EventArgs e) { for (int i = 0; i < listBox1.Items.Count; i++) { listBox2.Items.Add(listBox1.Items[i]); } listBox1.Items.Clear(); }
private void button5_Click(object sender, EventArgs e) { listBox1.Items.Add(textBox1.Text); textBox1.Text = ""; }
private void button10_Click(object sender, EventArgs e) { listBox2.Items.Add(textBox2.Text); textBox2.Text = ""; }
private void button6_Click(object sender, EventArgs e) { listBox1.Items.Remove(listBox1.SelectedItem); // Del 1 }
private void button9_Click(object sender, EventArgs e) { listBox2.Items.RemoveAt(listBox2.SelectedIndex); // Del 2 }
private void button8_Click(object sender, EventArgs e) { listBox2.Items.Clear(); }
private void button7_Click(object sender, EventArgs e) { listBox1.Items.Clear(); }
} } MaskedTextBox using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
namespace Test_1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }
private void button1_Click(object sender, EventArgs e) { MessageBox.Show("A"+maskedTextBox_SoXe.Text); } private void maskedTextBox_NgaySinh_Leave(object sender, EventArgs e) { DateTime t; if (!DateTime.TryParse(this.maskedTextBox_NgaySinh.Text, out t)) { this.maskedTextBox_NgaySinh.Text = ""; maskedTextBox_NgaySinh.Focus(); textBox_NgaySinh.Text = "Sai Rui"; } else { textBox_NgaySinh.Text = maskedTextBox_NgaySinh.Text; } } } }
SpitContainer using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Collections; // Goi ArrayList
namespace Splitcontainer_1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }
private void fixToolStripMenuItem_Click(object sender, EventArgs e) { splitContainer1.IsSplitterFixed = true; }
private void spliToolStripMenuItem_Click(object sender, EventArgs e) { splitContainer1.SplitterWidth = 100; }
private void setSplitterHeathToolStripMenuItem_Click(object sender, EventArgs e) { splitContainer1.SplitterDistance = 30; }
private void Form1_Load(object sender, EventArgs e) { ArrayList documents = new ArrayList();
#region A TreeNode A = new TreeNode("Documents"); A.Tag = documents;
TreeNode A1 = new TreeNode("Documents 1"); documents = new ArrayList(); documents.Add(new ListViewItem("Folder 1", 3)); documents.Add(new ListViewItem("Folder 2", 1)); documents.Add(new ListViewItem("Folder 3", 0)); A1.Tag = documents; #endregion #region B TreeNode B = new TreeNode("My Computer"); B.Tag = documents;
TreeNode B1 = new TreeNode("My Computer 1"); documents = new ArrayList(); documents.Add(new ListViewItem("Folder 1", 4)); documents.Add(new ListViewItem("Folder 2", 5)); documents.Add(new ListViewItem("Forler 3", 3)); documents.Add(new ListViewItem("Folder 4", 0)); B1.Tag = documents; #endregion #region C TreeNode C = new TreeNode("Pictures"); C.Tag = documents; TreeNode C1 = new TreeNode("My Pictures"); documents = new ArrayList(); documents.Add(new ListViewItem("Picture 1", 0)); documents.Add(new ListViewItem("Picture 2", 4)); documents.Add(new ListViewItem("Picture 3", 3)); C1.Tag = documents; #endregion A.Nodes.Add(A1); B.Nodes.Add(B1); C.Nodes.Add(C1); treeView1.Nodes.Add(A); treeView1.Nodes.Add(B); treeView1.Nodes.Add(C); treeView1.ImageList = imageList1; listView1.SmallImageList = imageList1; listView1.View = View.SmallIcon; } private void treeView1_BeforeCollapse(object sender, TreeViewCancelEventArgs e) { e.Node.ImageIndex = 0; e.Node.SelectedImageIndex = 0; } private void treeView1_BeforeExpand(object sender, TreeViewCancelEventArgs e) { e.Node.ImageIndex = 1; e.Node.SelectedImageIndex = 1; } private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { listView1.Items.Clear(); ArrayList doucument = (ArrayList)e.Node.Tag; foreach (ListViewItem i in doucument) { listView1.Items.Add(i); } } } }
Nhom_Wind(Listview&Treeview) using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
namespace baitap3 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private int thanhtien; private string giathanh; //private String trabang1;
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { if (treeView1.Nodes[0].Nodes[0].IsSelected) { listView1.Items.Clear(); listView1.Items.Add("ream"); listView1.Items[0].SubItems.Add("150 km/h"); listView1.Items[0].SubItems.Add("3000 "); listView1.Items.Add("ya mah"); listView1.Items[1].SubItems.Add("1334 km/h"); listView1.Items[1].SubItems.Add("555666"); } else if (treeView1.Nodes[0].Nodes[1].IsSelected) { listView1.Items.Clear(); listView1.Items.Add("way"); listView1.Items[0].SubItems.Add("200 km/h"); listView1.Items[0].SubItems.Add("5000 "); } else if (treeView1.Nodes[1].Nodes[0].IsSelected) { listView1.Items.Clear(); listView1.Items.Add("new moning"); listView1.Items[0].SubItems.Add("1000 km/h"); listView1.Items[0].SubItems.Add("7000 "); } else if (treeView1.Nodes[1].Nodes[1].IsSelected) { listView1.Items.Clear(); listView1.Items.Add("kia"); listView1.Items[0].SubItems.Add("12000 km/h"); listView1.Items[0].SubItems.Add("6000 "); listView1.Items.Add("moto"); listView1.Items[1].SubItems.Add("12000 km/h"); listView1.Items[1].SubItems.Add("9000 "); } } private void Form1_Load(object sender, EventArgs e) { soluong.Enabled = false; trabang.Enabled = false; }
private void button1_Click(object sender, EventArgs e) { MessageBox.Show("ten " + listView1.SelectedItems[0].SubItems[0].Text + "\nphan kho :" + listView1.SelectedItems[0].SubItems[1].Text + "\nso luong : " + soluong.Value + "\nthanh tien : " + giathanh + "\ntra bang : " + trabang.Text); }
private void listView1_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { if (listView1.SelectedItems.Count > 0) { soluong.Enabled = true; trabang.Enabled = true; thanhtien = int.Parse(e.Item.SubItems[2].Text); } else { soluong.Enabled = false; trabang.Enabled = false; } }
private void soluong_ValueChanged(object sender, EventArgs e) { giathanh = (thanhtien * soluong.Value).ToString(); tienmoney.Text = giathanh; } } } Nhom_Wind (ProcessBar) using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
namespace tt { public partial class Email : Form { public Email() { InitializeComponent(); } private void button3_Click(object sender, EventArgs e) { FontStyle style = richTextBox1.SelectionFont.Style;
if (richTextBox1.SelectionFont.Underline) { style = style & ~FontStyle.Underline; button3.Font = new Font(button3.Font, FontStyle.Regular); } else { style = style | FontStyle.Underline; button3.Font = new Font(button3.Font, FontStyle.Bold); } richTextBox1.SelectionFont = new Font(richTextBox1.SelectionFont, style); richTextBox1.Focus(); } private void button8_Click(object sender, EventArgs e) { Close(); } private void textBox1_Leave(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show("Vui long dien dia chi email can gui!", "E-Mail", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox1.Focus(); } }
private void Email_Load_1(object sender, EventArgs e) { textBox1.Focus(); } private void button1_Click(object sender, EventArgs e) { FontStyle style = richTextBox1.SelectionFont.Style; if (richTextBox1.SelectionFont.Bold) { style = style & ~FontStyle.Bold; button1.Font = new Font(button1.Font, FontStyle.Regular); } else { style = style | FontStyle.Bold; button1.Font = new Font(button1.Font, FontStyle.Bold); } richTextBox1.SelectionFont = new Font(richTextBox1.SelectionFont, style); richTextBox1.Focus(); }
private void button2_Click(object sender, EventArgs e) { FontStyle style = richTextBox1.SelectionFont.Style;
if (richTextBox1.SelectionFont.Italic) { style = style & ~FontStyle.Italic; button2.Font = new Font(button2.Font, FontStyle.Regular); } else { style = style | FontStyle.Italic; button2.Font = new Font(button2.Font, FontStyle.Bold); } richTextBox1.SelectionFont = new Font(richTextBox1.SelectionFont,style); richTextBox1.Focus(); } private void button4_Click(object sender, EventArgs e) { richTextBox1.SelectionAlignment = HorizontalAlignment.Left; if (button4.Font.Bold) button4.Font = new Font(button4.Font, FontStyle.Regular); else button4.Font = new Font(button4.Font, FontStyle.Bold); richTextBox1.Focus(); } private void button5_Click(object sender, EventArgs e) { richTextBox1.SelectionAlignment = HorizontalAlignment.Center; if (button5.Font.Bold) button5.Font = new Font(button5.Font, FontStyle.Regular); else button5.Font = new Font(button5.Font, FontStyle.Bold); richTextBox1.Focus(); }
private void button6_Click(object sender, EventArgs e) { richTextBox1.SelectionAlignment = HorizontalAlignment.Right; if (button6.Font.Bold) button6.Font = new Font(button6.Font, FontStyle.Regular); else button6.Font = new Font(button6.Font, FontStyle.Bold); button6.Focus(); }
private void progressBar1_Click(object sender, EventArgs e) { progressBar1.Visible = true; progressBar1.Maximum = 1000000; progressBar1.Minimum = 0; progressBar1.Step = 1; for (int i = 0; i < 1000000; i++) { //Làm cái gi` ðó progressBar1.PerformStep(); } MessageBox.Show("Gui Thanh Cong!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); progressBar1.Value = 0; progressBar1.Visible = false;
} } }
Nhom_Wind (RichTextBox) using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
namespace tt { public partial class Email : Form { public Email() { InitializeComponent(); } private void button3_Click(object sender, EventArgs e) { FontStyle style = richTextBox1.SelectionFont.Style;
if (richTextBox1.SelectionFont.Underline) { style = style & ~FontStyle.Underline; button3.Font = new Font(button3.Font, FontStyle.Regular); } else { style = style | FontStyle.Underline; button3.Font = new Font(button3.Font, FontStyle.Bold); } richTextBox1.SelectionFont = new Font(richTextBox1.SelectionFont, style); richTextBox1.Focus(); }
private void button8_Click(object sender, EventArgs e) { Close(); }
private void button7_Click(object sender, EventArgs e) { if (textBox2.Text == "") { DialogResult h = (MessageBox.Show("Ban muon gui mail khong co chu de", "E-Mail", MessageBoxButtons.OKCancel, MessageBoxIcon.Information)); if (h == DialogResult.OK) { MessageBox.Show("Gui thanh cong!","E-Mail", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { textBox2.Focus(); if (textBox2.Text != "") { MessageBox.Show("Gui thanh cong!" + ".", "E-Mail", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else MessageBox.Show("Gui thanh cong!", "E-Mail", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void textBox1_Leave(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show("Vui long dien dia chi email can gui!", "E-Mail", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox1.Focus(); } }
private void Email_Load_1(object sender, EventArgs e) { textBox1.Focus(); }
private void button1_Click(object sender, EventArgs e) { FontStyle style = richTextBox1.SelectionFont.Style; if (richTextBox1.SelectionFont.Bold) { style = style & ~FontStyle.Bold; button1.Font = new Font(button1.Font, FontStyle.Regular); } else { style = style | FontStyle.Bold; button1.Font = new Font(button1.Font, FontStyle.Bold); } richTextBox1.SelectionFont = new Font(richTextBox1.SelectionFont, style); richTextBox1.Focus(); }
private void button2_Click(object sender, EventArgs e) { FontStyle style = richTextBox1.SelectionFont.Style;
if (richTextBox1.SelectionFont.Italic) { style = style & ~FontStyle.Italic; button2.Font = new Font(button2.Font, FontStyle.Regular); } else { style = style | FontStyle.Italic; button2.Font = new Font(button2.Font, FontStyle.Bold); } richTextBox1.SelectionFont = new Font(richTextBox1.SelectionFont,style); richTextBox1.Focus(); }
private void button4_Click(object sender, EventArgs e) { richTextBox1.SelectionAlignment = HorizontalAlignment.Left; if (button4.Font.Bold) button4.Font = new Font(button4.Font, FontStyle.Regular); else button4.Font = new Font(button4.Font, FontStyle.Bold); richTextBox1.Focus(); }
private void button5_Click(object sender, EventArgs e) { richTextBox1.SelectionAlignment = HorizontalAlignment.Center; if (button5.Font.Bold) button5.Font = new Font(button5.Font, FontStyle.Regular); else button5.Font = new Font(button5.Font, FontStyle.Bold); richTextBox1.Focus(); }
private void button6_Click(object sender, EventArgs e) { richTextBox1.SelectionAlignment = HorizontalAlignment.Right; if (button6.Font.Bold) button6.Font = new Font(button6.Font, FontStyle.Regular); else button6.Font = new Font(button6.Font, FontStyle.Bold); button6.Focus(); }
private void progressBar1_Click(object sender, EventArgs e) {
} } }
NhomTai(DongHo) using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
namespace dongho { public partial class Form1 : Form { public Form1() { InitializeComponent(); }
private void timer1_Tick(object sender, EventArgs e) { label1.Text = DateTime.Now.ToString(); }
private void Form1_Load(object sender, EventArgs e) { timer1.Start(); } } }
NhomTai (Timer) using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
namespace demo_Timer { public partial class Form1 : Form { int count = 100; public Form1() { InitializeComponent(); button2.Enabled = false; }
private void timer1_Tick(object sender, EventArgs e) { count--; if (count == 0) { timer1.Stop(); } label1.Text = count.ToString(); }
private void button1_Click(object sender, EventArgs e) { button2.Enabled = true; button1.Enabled = false; timer1.Start(); }
private void button2_Click(object sender, EventArgs e) { button1.Enabled = true; timer1.Stop(); } } }
NhomTai (DateTimeCalendar) using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
namespace demo_Timer { public partial class Form1 : Form { int count = 100; public Form1() { InitializeComponent(); button2.Enabled = false; }
private void timer1_Tick(object sender, EventArgs e) { count--; if (count == 0) { timer1.Stop(); } label1.Text = count.ToString(); }
private void button1_Click(object sender, EventArgs e) { button2.Enabled = true; button1.Enabled = false; timer1.Start(); }
private void button2_Click(object sender, EventArgs e) { button1.Enabled = true; timer1.Stop(); } } }
NhomTai (MonthCalendar) using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
namespace Demo_MonthCalendar { public partial class Form1 : Form { string date; public Form1() { InitializeComponent(); }
private void btDemension_Click(object sender, EventArgs e) { if (txHeigh.Text==""&&txWidth.Text=="") { MessageBox.Show("Nhap Heigh va Width"); txHeigh.Focus(); } else if (txHeigh.Text == "" ) { MessageBox.Show("Nhap Heigh"); txHeigh.Focus(); } else if (txWidth.Text == "") { MessageBox.Show("Nhap Width"); txWidth.Focus(); } else { int a = int.Parse(txHeigh.Text); int b = int.Parse(txWidth.Text); Size s = new Size(b, a); monthCalendar1.CalendarDimensions = s;
} }
private void btShowToday_Click(object sender, EventArgs e) { if (monthCalendar1.ShowToday == false) { monthCalendar1.ShowToday = true; } else { monthCalendar1.ShowToday = false; } }
private void btTodaycircle_Click(object sender, EventArgs e) { if (monthCalendar1.ShowTodayCircle == false) { monthCalendar1.ShowTodayCircle = true; } else { monthCalendar1.ShowTodayCircle = false; } }
private void btweek_Click(object sender, EventArgs e) { if (monthCalendar1.ShowWeekNumbers == false) { monthCalendar1.ShowWeekNumbers = true; } else { monthCalendar1.ShowWeekNumbers = false; } }
private void btToday_Click(object sender, EventArgs e) { monthCalendar1.TodayDate = monthCalendar1.SelectionRange.End; }
} }
NhomTai (ChonNgay) using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
namespace demo { public partial class Form1 : Form { int dem=0; string ngay; public Form1() { InitializeComponent(); }
private void Form1_Load(object sender, EventArgs e) { //dem = 0; DateTime a=new DateTime(2010,08,08); dateTimePicker1.Value = a; }
private void button1_Click(object sender, EventArgs e) { MessageBox.Show(dateTimePicker1.Value.ToShortDateString()); }
private void button2_Click(object sender, EventArgs e) { dateTimePicker1.Focus(); }
private void button3_Click(object sender, EventArgs e) { dateTimePicker1.Show(); }
private void dateTimePicker1_ValueChanged(object sender, EventArgs e) { MessageBox.Show("da thay doi!"); }
private void button4_Click(object sender, EventArgs e) { dateTimePicker1.Format = DateTimePickerFormat.Short; }
private void dateTimePicker1_FormatChanged(object sender, EventArgs e) { MessageBox.Show("Format changed"); }
private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e) {
} private void button5_Click(object sender, EventArgs e) {
monthCalendar1.AddBoldedDate (monthCalendar1.SelectionRange.End); //dem++; MessageBox.Show(monthCalendar1.SelectionRange.End.ToString()); monthCalendar1.Refresh(); }
private void button6_Click(object sender, EventArgs e) { for (int i = 0; i < monthCalendar1.BoldedDates.Length; i++) { ngay += monthCalendar1.BoldedDates[i].ToString()+"..."; } MessageBox.Show(ngay, "Nhung ngay da danh dau"); } } }
|
|