亞當我剛剛實施的這是一個非常簡單的版本,它的工作原理完全如預期...
下面是比較初始化代碼
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());
}
它可以工作,因爲我把股票移動到每個額外的增量...
Aaargh!你是對的,它確實有效。我在代碼的其他地方發現了一個錯誤,它阻止了trackbar滾動處理程序被調用。在發佈到堆棧溢出之前,我應該更仔細地檢查這些事情。 雖然這是一個很好的代碼示例,所以我會將其作爲公認的答案。 – 2009-05-21 11:39:24