ToolTip控件

来源:互联网 发布:mac系统ai快捷键 编辑:程序博客网 时间:2024/05/17 19:20

 题目要求:

     窗体中有一个图片框,显示一副图片。要求:1)在窗体打开时,动态加载图片;2)设置图片显示模式为根据图片框大小缩放图片;3)图片自己找;4)当鼠标停留在图片框时,显示如“北京风光”的文本提示(使用ToolTip控件)。


输入代码:

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace 第12周上机3_1{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();        }        private void Form1_Load(object sender, EventArgs e)        {            this.pictureBox1.Image = Image.FromFile("4.jpg");            this.pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;            toolTip1.SetToolTip(pictureBox1, "北京风光");        }        private void toolTip1_Popup(object sender, PopupEventArgs e)        {        }    }}


运行截图:



0 0