Application









How do I use Application
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: Form9.cs Copy
20         private void btnThoat_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
21         {
22             Application.Exit();
23         }
File name: FormXemDiem.cs Copy
85         private void btnXuatRaExcel_Click(object sender, EventArgs e)
86         {
87             try
88             {
89
90                 Excel.Application objExcelApp = new Excel.Application();
91                 Excel.Workbook objExcelWorkbook = objExcelApp.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet);
92                 Excel.Worksheet objSheet = (Excel.Worksheet)objExcelWorkbook.Worksheets[1];
93                 //objSheet.Cells.Interior.Color.ToString() = 'blue';
94                 objSheet = (Excel.Worksheet)objExcelWorkbook.Sheets[1];
95                 objSheet.Cells.HorizontalAlignment = Excel.Constants.xlCenter;
96                 objSheet.Cells[2, 5] = "BẢNG ĐIỂM CỦA SINH VIÊN";
97                 objSheet.Cells[5, 3] = "Mã Học Phần";
98                 objSheet.Cells[5, 4] = "Mã Nhóm Học Phần";
99                 objSheet.Cells[5, 5] = "Tên Học Phần";
100                 objSheet.Cells[5, 6] = "Điểm Thi";
101                 objSheet.Cells[5, 7] = "Điểm Quá Trình";
102                 objSheet.Cells[5, 8] = "Điểm Xếp Loại";
103                 objSheet.Cells[3, 3] = "Mã Học Kỳ : "+cmbMaHK.SelectedValue.ToString()+"";
104                 objSheet.Cells[4, 3] = "Mã SV : " + txtMaSV.Text + "";
105                 objSheet.Cells[9,10] = "ĐIỂM TỔNG KẾT";
106                 objSheet.Cells[10,10] = "Hệ 10 : "+txtHe10.Text+"";
107                 objSheet.Cells[11,10] = "Hệ 4 : "+txtHe4.Text+"";
108                 for (int i = 0; i < dgvKetQua.Rows.Count ; i++)
109                 {
110                     for (int j = 0; j < dgvKetQua.Columns.GetColumnCount(DataGridViewElementStates.Displayed); j++)
111                     {
112                         objSheet.Cells[i + 6, j + 3] = dgvKetQua.Rows[i].Cells[j].Value.ToString();
113                         objSheet.Columns.AutoFit();
114                     }
115                 }
116                 objExcelApp.Visible = true;
117             }
118             catch (Exception ex)
119             {
120                 MessageBox.Show(ex.Message);
121             }
122         }
File name: FormXemDiemLop.cs Copy
77         private void btnXuatRaExcel_Click(object sender, EventArgs e)
78         {
79              try
80             {
81
82                 Excel.Application objExcelApp = new Excel.Application();
83                 Excel.Workbook objExcelWorkbook = objExcelApp.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet);
84                 Excel.Worksheet objSheet = (Excel.Worksheet)objExcelWorkbook.Worksheets[1];
85                 //objSheet.Cells.Interior.Color.ToString() = 'blue';
86                 objSheet = (Excel.Worksheet)objExcelWorkbook.Sheets[1];
87                 objSheet.Cells.HorizontalAlignment = Excel.Constants.xlCenter;
88                 objSheet.Cells[2, 5] = "BẢNG ĐIỂM CỦA LỚP";
89                 objSheet.Cells[3, 3] = "Mã Học Kỳ : "+cmbMaHK.SelectedValue.ToString()+"";
90                 objSheet.Cells[4, 3] = "Mã Lớp : " + cmbMaLop.SelectedValue.ToString() + "";
91                 objSheet.Cells[5, 4] = "Mã Sinh Viên";
92                 objSheet.Cells[5, 5] = "Tên Sinh Viên";
93                 objSheet.Cells[5, 6] = "Điểm Trung Bình";
94                 //select sv.MaSV,TenSV,TrungBinhCuoiKyHe10
95
96                 for (int i = 0; i < dgvKetQua.Rows.Count ; i++)
97                 {
98                     for (int j = 0; j < dgvKetQua.Columns.GetColumnCount(DataGridViewElementStates.Displayed); j++)
99                     {
100                         objSheet.Cells[i + 6, j + 4] = dgvKetQua.Rows[i].Cells[j].Value.ToString();
101                         objSheet.Columns.AutoFit();
102                     }
103                 }
104                 objExcelApp.Visible = true;
105             }
106             catch (Exception ex)
107             {
108                 MessageBox.Show(ex.Message);
109             }
110         }
File name: Program.cs Copy
14         static void Main()
15         {
16             Application.EnableVisualStyles();
17             Application.SetCompatibleTextRenderingDefault(false);
18             Application.Run(new Form9());
19         }
File name: frmCapNhat.cs Copy
367         private void buton1_Click(object sender, EventArgs e)
368         {
369             float i = 50;
370             if (buton1.Text == "Thu Nhỏ")
371             {
372                 while (this.Height > 370)
373                 {
374                     i += 1f;
375                     this.Height -= (int)i;
376                     Application.DoEvents();
377                     buton1.Text = "Mở Rộng";
378                 }
379             }
380             else
381             {
382
383                 while (this.Height < 600)
384                 {
385                     i += 1f;
386                     this.Height += (int)i;
387                     Application.DoEvents();
388                     buton1.Text = "Thu Nhỏ";
389                 }
390             }
391         }
File name: frmMain.cs Copy
41         private void button1_Click(object sender, EventArgs e)
42         {
43             if (MessageBox.Show("Bạn có chắc chắn muốn thoát ?","Thông báo",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.OK)
44
45             {
46                 Application.Exit();
47
48             }
49         }
File name: frmMain.cs Copy
51         private void thoátToolStripMenuItem1_Click(object sender, EventArgs e)
52         {
53             if (MessageBox.Show("Bạn có chắc chắn muốn thoát ?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
54             {
55                 Application.Exit();
56
57             }
58         }
File name: frmMain.cs Copy
60         private void thoátToolStripMenuItem2_Click(object sender, EventArgs e)
61         {
62             Application.Exit();
63         }
File name: frmMain.cs Copy
113         private void thoátToolStripMenuItem2_Click_1(object sender, EventArgs e)
114         {
115             if (MessageBox.Show("Bạn có chắc chắn muốn thoát ?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
116             {
117                 Application.Exit();
118
119             }
120         }
File name: Program.cs Copy
14         static void Main()
15         {
16             Application.EnableVisualStyles();
17             Application.SetCompatibleTextRenderingDefault(false);
18             Application.Run(new frmMain());
19         }

Download file with original file name:Application

Application 123 lượt xem

Gõ tìm kiếm nhanh...