using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ConsoleApplication4
{
class AForm : Form
{
Label gt;
TextBox textbox;
Button btn;
Menu menu;
TextBox textbox2, kq;
public AForm()
{
/* textbox = new TextBox();
textbox.Location = new System.Drawing.Point(10,10);
//textbox.TextAlign =
this.Controls.Add(textbox);
textbox2 = new TextBox();
textbox2.Location = new System.Drawing.Point(10, 50);
//textbox2.TextAlign = ("Nhap so a");
this.Controls.Add(textbox2);
btn = new Button();
btn.Location = new System.Drawing.Point(10, 80);
btn.Text = "Tong";
this.Controls.Add(btn);
this.btn.Click += new EventHandler(btn_Click);
kq = new TextBox();
kq.Location = new System.Drawing.Point(10, 110);
kq.Text = "";
this.Controls.Add(kq);
*/
RichTextBox richTB = new RichTextBox();
richTB.Size=new System.Drawing.Size(this.Height,this.Width);
this.Controls.Add(richTB);
gt = new Label();
gt.Text = "";
gt.Anchor = AnchorStyles.Bottom;
this.Controls.Add(gt);
MainMenu menu = new MainMenu();
MenuItem file = new MenuItem();
file.Text = "&File";
MenuItem format = new MenuItem();
format.Text = "&Format";
MenuItem edit = new MenuItem();
edit.Text = "&Edit";
MenuItem file_new = new MenuItem();
file_new.Text = "&New";
MenuItem file_open = new MenuItem();
file_open.Text = "&Open";
file.MenuItems.Add(file_new);
file.MenuItems.Add(file_open);
menu.MenuItems.Add(file);
menu.MenuItems.Add(format);
menu.MenuItems.Add(edit);
file_open.ShowShortcut = true;
file_open.Shortcut = Shortcut.CtrlO;
file_new.ShowShortcut = true;
file_new.Shortcut = Shortcut.CtrlN;
file_open.Click += new EventHandler(open_click);
file_new.Click += new EventHandler(new_click);
file_open.Select += new EventHandler(ShowInfo);
file_new.Select += new EventHandler(ShowInfo);
this.Menu=menu;
}
public void ShowInfo(Object o, EventArgs e)
{
MenuItem item= (MenuItem)o;
String name = item.Text;
// MessageBox.Show(name);
this.gt.Text = name;
}
public void open_click(Object o, EventArgs e)
{
MessageBox.Show("Đã nhấn Open");
}
public void new_click(Object o, EventArgs e)
{
MessageBox.Show("Đã nhấn New");
}
public void btn_Click(Object o, EventArgs e)
{
double a, b;
if (double.TryParse(this.textbox.Text,out a) == false || double.TryParse(this.textbox2.Text, out b) == false)
{
MessageBox.Show("VUi long nhap dung dinh dang");
return;
}
//double a = double.Parse(this.textbox.Text);
//double b = double.Parse(this.textbox2.Text);
kq.Text = ((a + b).ToString());
}
}
class Program
{
static void Main(string[] args)
{
AForm f = new AForm();
Application.Run(f);
}
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.