C#toolTip应用

来源:互联网 发布:js弹出一个window窗口 编辑:程序博客网 时间:2024/05/17 07:46
namespace WindowsFormsApplication1{    partial class Form1    {        /// <summary>        /// 必需的设计器变量。        /// </summary>        private System.ComponentModel.IContainer components = null;        /// <summary>        /// 清理所有正在使用的资源。        /// </summary>        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>        protected override void Dispose(bool disposing)        {            if (disposing && (components != null))            {                components.Dispose();            }            base.Dispose(disposing);        }        #region Windows 窗体设计器生成的代码        /// <summary>        /// 设计器支持所需的方法 - 不要        /// 使用代码编辑器修改此方法的内容。        /// </summary>        private void InitializeComponent()        {            this.components = new System.ComponentModel.Container();            this.pictureBox1 = new System.Windows.Forms.PictureBox();            this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();            this.SuspendLayout();            //             // pictureBox1            //             this.pictureBox1.Anchor = System.Windows.Forms.AnchorStyles.None;            this.pictureBox1.Location = new System.Drawing.Point(67, 25);            this.pictureBox1.Name = "pictureBox1";            this.pictureBox1.Size = new System.Drawing.Size(426, 275);            this.pictureBox1.TabIndex = 0;            this.pictureBox1.TabStop = false;            this.pictureBox1.MouseEnter += new System.EventHandler(this.pictureBox1_MouseEnter);            //             // Form1            //             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;            this.ClientSize = new System.Drawing.Size(570, 324);            this.Controls.Add(this.pictureBox1);            this.Name = "Form1";            this.Text = "Form1";            this.Load += new System.EventHandler(this.Form1_Load);            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();            this.ResumeLayout(false);        }        #endregion        private System.Windows.Forms.PictureBox pictureBox1;        private System.Windows.Forms.ToolTip toolTip1;    }}


 

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 WindowsFormsApplication1{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();        }        private void Form1_Load(object sender, EventArgs e)        {            toolTip1.Active = true;            this.pictureBox1.Image = Image.FromFile(@"D:\u=2407710322,4021140033&fm=23&gp=0.jpg");//动态加载图片            this.pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;//设置图片显示方式            pictureBox1.Anchor = (AnchorStyles.Bottom|AnchorStyles.Left|AnchorStyles.Right| AnchorStyles.Top);        }        private void pictureBox1_MouseEnter(object sender, EventArgs e)        {            toolTip1.SetToolTip(pictureBox1,"暗黑血统2");        }    }}


0 0
原创粉丝点击