我使用了microsoft的示例代码来创建任务栏,但我无法用它来创建多个任务栏
这是我正在使用的代码
public class form1
{
private System.Windows.Forms.TrackBar trackBar1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TrackBar trackBar2;
private System.Windows.Forms.TextBox textBox2;
public Form1()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.trackBar1 = new System.Windows.Forms.TrackBar();
// TextBox for TrackBar.Value update.
this.textBox1.Location = new System.Drawing.Point(240, 0);
this.textBox1.Size = new System.Drawing.Size(48, 20);
// Set up how the form should be displayed and add the controls to the form.
this.ClientSize = new System.Drawing.Size(296, 62);
this.Controls.AddRange(new System.Windows.Forms.Control[]
{
this.textBox1, this.trackBar1
});
this.Text = "TrackBar Example";
// Set up the TrackBar.
this.trackBar1.Location = new System.Drawing.Point(0, 0);
this.trackBar1.Size = new System.Drawing.Size(224, 45);
trackBar1.Maximum = 255;
this.textBox2 = new System.Windows.Forms.TextBox();
this.trackBar2 = new System.Windows.Forms.TrackBar();
// TextBox for TrackBar.Value update.
this.textBox2.Location = new System.Drawing.Point(240, 800);
this.textBox2.Size = new System.Drawing.Size(48, 20);
// Set up how the form should be displayed and add the controls to the form.
this.ClientSize = new System.Drawing.Size(296, 62);
this.Controls.AddRange(new System.Windows.Forms.Control[]
{
this.textBox1, this.trackBar1
});
this.Text = "TrackBar Example";
// Set up the TrackBar.
this.trackBar2.Location = new System.Drawing.Point(0, 100);
this.trackBar2.Size = new System.Drawing.Size(224, 45);
trackBar2.Maximum = 255;
}
}
当我使用trackbar1时,当我定义trackbar1&时,它运行得非常好。 trackbar2,我只看到trackbar1而不是trackbar2。代码没有错误
注意:这不是整个代码,只是一个代码段
答案 0 :(得分:1)
你必须稍微扩大你的形状并改变:
this.Controls.AddRange(new System.Windows.Forms.Control[] { this.textBox1, this.trackBar1 });
到
this.Controls.AddRange(new System.Windows.Forms.Control[] { this.textBox2, this.trackBar2 });
在trackBar2。
另外要查看TextBox2,您需要更改
this.textBox2.Location = new System.Drawing.Point(240, 800);
到
this.textBox2.Location = new System.Drawing.Point(240, 100);
此致