code duoi ko pro dau chi tham khảo thui.
code pro thi ko share đâu
Tải Về
code menu
- Code:
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 baituan4
{
public partial class menu : Form
{
public menu()
{
InitializeComponent();
}
private void tbthem_Click(object sender, EventArgs e)
{
int chuyen;
try
{
chuyen = Convert.ToInt32(tbnhap.Text);
this.listBox1.Items.Add(chuyen);
tbnhap.Text = "";
}
catch
{
MessageBox.Show("Bạn chưa nhập vào giá trị\n Hoặc nhập số quá lớn.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
private void btxoa_Click(object sender, EventArgs e)
{
int i = this.listBox1.SelectedIndex;
if (i >= 0)
this.listBox1.Items.RemoveAt(i);
else
MessageBox.Show("Chọn vị trí muốn xóa");
}
private void btsua_Click(object sender, EventArgs e)
{
int i = this.listBox1.SelectedIndex;
if (i >= 0)
{
this.listBox1.Items.RemoveAt(i);
this.listBox1.Items.Insert(i, tbnhap.Text);
}
else
MessageBox.Show("Chọn vị trí muốn sua");
}
private void btxoaall_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
tbnhap.Clear();
lisboxxuat.Clear();
}
private void henGioToolStripMenuItem_Click(object sender, EventArgs e)
{
byebye tat = new byebye ();
tat.Show();
}
private void doiTienToolStripMenuItem_Click(object sender, EventArgs e)
{
doitien dt = new doitien();
dt.Show();
}
private void formNhaKhoaToolStripMenuItem_Click(object sender, EventArgs e)
{
tramrang nk = new tramrang();
nk.Show();
}
private void thoátToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void thoatToolStripMenuItem_Click(object sender, EventArgs e)
{
dongho dh = new dongho();
dh.Show();
}
private void button7_Click(object sender, EventArgs e)
{
int t,result = 0;
for (int i = 0, icount = listBox1.Items.Count; i < icount; ++i)
{
t = Convert.ToInt32(listBox1.Items[i].ToString());
if (t % 2 == 0)
{
result += Convert.ToInt32(listBox1.Items[i].ToString());
lisboxxuat.Text = result.ToString();
}
}
}
private void button8_Click(object sender, EventArgs e)
{
int t, tong = 0;
for (int i = 0, icount = listBox1.Items.Count; i < icount; ++i)
{
t = Convert.ToInt32(listBox1.Items[i].ToString());
if (t % 2 != 0)
{
tong += Convert.ToInt32(listBox1.Items[i].ToString());
lisboxxuat.Text = "\n" + tong.ToString();
}
}
}
private void button5_Click(object sender, EventArgs e)
{
int max = 0, t;
try
{
for (int i = 0, icount = listBox1.Items.Count; i < icount; ++i)
{
t = Convert.ToInt32(listBox1.Items[i].ToString());
if (max < t)
{
max = t;
lisboxxuat.Text = "\n" + max.ToString();
}
}
}
catch
{
MessageBox.Show("Đã Có Lỗi Xảy Ra Có thể Số quá lớn");
}
}
private void tbnhap_KeyPress(object sender, KeyPressEventArgs e)
{
if (!Char.IsDigit(e.KeyChar) && !Char.IsControl(e.KeyChar))
{
e.Handled = true;
MessageBox.Show("Vui lòng nhập số.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
private void tbnhap_TextChanged(object sender, EventArgs e)
{
}
private void lisboxxuat_TextChanged(object sender, EventArgs e)
{
}
private void btmin_Click(object sender, EventArgs e)
{
int t;
int min = Convert.ToInt32(listBox1.Items[0].ToString());
for (int i = 0, icount = listBox1.Items.Count; i < icount; i++)
{
t = Convert.ToInt32(listBox1.Items[i].ToString());
if (t < min)
{
min = t;
lisboxxuat.Text = "\n" + min.ToString();
}
}
}
}
}