C# VisualStudio中的多个轨迹栏
我已经使用microsoft的示例代码创建了一个任务栏,但无法使用它创建多个任务栏 这是我正在使用的代码C# VisualStudio中的多个轨迹栏,c#,visual-studio,C#,Visual Studio,我已经使用microsoft的示例代码创建了一个任务栏,但无法使用它创建多个任务栏 这是我正在使用的代码 public class form1 { private System.Windows.Forms.TrackBar trackBar1; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.TrackBar trackBar2; private System.
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。代码没有给出错误
注意:这不是全部代码,只是一个代码片段,您需要进一步放大表单并更改:
this.Controls.AddRange(new System.Windows.Forms.Control[] { this.textBox1, this.trackBar1 });
到
在轨迹栏中
此外,要查看文本框2,您需要更改
this.textBox2.Location = new System.Drawing.Point(240, 800);
到
这是一个好问题。非常感谢。
this.textBox2.Location = new System.Drawing.Point(240, 800);
this.textBox2.Location = new System.Drawing.Point(240, 100);