您的位置:首页 > 编程语言 > C#

C#—实验10.1和10.2

2016-06-03 17:21 351 查看
/*
* (1)当用户在richBox中单击鼠标右键时,弹出一个快捷菜单,单击某地名,即可在richBox中显示该地旅游景点。
* (2)添加工具栏控件。在工具栏中添加两个控件,并给这两个按钮添加图片和提示文本(通过ToolTipText属性实现)。启动窗体时,初始字体为宋体12号字。
*/
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 Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
this.Text = "快捷菜单";
richTextBox1.Font = new Font("宋体", 12);
}

private void 北京ToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Text = "颐和园,长城,故宫";
}

private void 南京ToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Text = "中山陵,玄武湖,夫子庙";
}

private void 西安ToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Text = "秦始皇兵马俑,大雁塔";
}

private void 青岛ToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Text = "崂山,栈桥,五四广场";
}

private void 上海ToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Text = "世博会,东方明珠";
}

private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
switch (e.ClickedItem.Name)
{
case "toolStripButton1":
richTextBox1.Font = new Font("黑体", richTextBox1.Font.Size );
break;
case "toolStripButton2":
richTextBox1.Font = new Font(richTextBox1.Font.FontFamily, 20);
break;
}
}
}
}

运行结果:



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c#