我是 C# 和 WinForms 的新手,所以请原谅,这是一个新手问题。
我正在尝试向 TrackBar 控件添加一个工具提示,该提示在您拖动该栏时显示该栏的当前值。我已经实例化了一个 ToolTip 对象并尝试了以下处理程序代码,但它没有显示任何工具提示:
private void trackBar1_Scroll(object sender, EventArgs e)
{
toolTip1.SetToolTip(trackBar1, trackBar1.Value.ToString());
}
Adam 我刚刚实现了一个非常简单的版本,它的工作原理完全符合预期......
这是用于比较的初始化代码
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.trackBar1 = new System.Windows.Forms.TrackBar();
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
this.SuspendLayout();
//
// trackBar1
//
this.trackBar1.Location = new System.Drawing.Point(12, 166);
this.trackBar1.Name = "trackBar1";
this.trackBar1.Size = new System.Drawing.Size(268, 42);
this.trackBar1.TabIndex = 1;
this.trackBar1.Scroll += new System.EventHandler(this.trackBar1_Scroll);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.trackBar1);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
private void trackBar1_Scroll(object sender, EventArgs e)
{
toolTip1.SetToolTip(trackBar1, trackBar1.Value.ToString());
}
当我将股票代码移动到每个额外的增量时,它就会起作用......
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)