C# trackBar 滑动条控件 问题
第一次使用trackBar求高手指点我放了2个trackBar控件需要他们像杠杆一样关联起来(上面拉动,下面会随之变化)还要将trackBar控件的默认拉动按钮设置在中间...
第一次使用trackBar 求高手指点
我放了2个 trackBar 控件
需要他们像杠杆一样关联起来(上面拉动,下面会随之变化)
还要 将trackBar 控件的默认拉动按钮设置在中间
再让trackBar 每次的拉动距离缩短(现在设为1,也是一跳一节)
再把trackBar 的值用lable显示出来
坐等高手 展开
我放了2个 trackBar 控件
需要他们像杠杆一样关联起来(上面拉动,下面会随之变化)
还要 将trackBar 控件的默认拉动按钮设置在中间
再让trackBar 每次的拉动距离缩短(现在设为1,也是一跳一节)
再把trackBar 的值用lable显示出来
坐等高手 展开
展开全部
public partial class TrackBarForm : Form
{
public TrackBarForm()
{
InitializeComponent();
setTrackBar();
}
private void trackBar1_Scroll(object sender, EventArgs e)
{
relationTrackBarChange(this.trackBar1.Value,"trackBar1");
}
private void trackBar2_Scroll(object sender, EventArgs e)
{
relationTrackBarChange(this.trackBar2.Value,"trackBar2");
}
private void setTrackBar()
{
this.trackBar1.Maximum = 100;
this.trackBar1.Minimum = 0;
this.trackBar2.Maximum = 100;
this.trackBar2.Minimum = 0;
trackBar1.Value = 50;
trackBar2.Value = 50;
}
private void relationTrackBarChange(int changeValue,string flg)
{
int otherTrackValue = 100 - changeValue;
if ("trackBar1".Equals(flg))
{
this.trackBar2.Value = otherTrackValue;
}
if ("trackBar2".Equals(flg))
{
this.trackBar1.Value = otherTrackValue;
}
this.label1.Text = this.trackBar1.Value.ToString();
this.label2.Text = this.trackBar2.Value.ToString();
}
}
{
public TrackBarForm()
{
InitializeComponent();
setTrackBar();
}
private void trackBar1_Scroll(object sender, EventArgs e)
{
relationTrackBarChange(this.trackBar1.Value,"trackBar1");
}
private void trackBar2_Scroll(object sender, EventArgs e)
{
relationTrackBarChange(this.trackBar2.Value,"trackBar2");
}
private void setTrackBar()
{
this.trackBar1.Maximum = 100;
this.trackBar1.Minimum = 0;
this.trackBar2.Maximum = 100;
this.trackBar2.Minimum = 0;
trackBar1.Value = 50;
trackBar2.Value = 50;
}
private void relationTrackBarChange(int changeValue,string flg)
{
int otherTrackValue = 100 - changeValue;
if ("trackBar1".Equals(flg))
{
this.trackBar2.Value = otherTrackValue;
}
if ("trackBar2".Equals(flg))
{
this.trackBar1.Value = otherTrackValue;
}
this.label1.Text = this.trackBar1.Value.ToString();
this.label2.Text = this.trackBar2.Value.ToString();
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
留个联系方式,我们探讨一下,
这个其实非常简单:
public Form1()
{
InitializeComponent();
int t1 = trackBar1.Maximum;
double t2 = t1 / 2;
trackBar1.Value = int.Parse(Math.Ceiling(Decimal.Parse(t2.ToString())).ToString());
trackBar2.Value = trackBar1.Value;
}
private void trackBar1_Scroll(object sender, EventArgs e)
{
label1.Text = trackBar1.Value.ToString();
trackBar2.Value = trackBar1.Maximum - trackBar1.Value;
}
这个其实非常简单:
public Form1()
{
InitializeComponent();
int t1 = trackBar1.Maximum;
double t2 = t1 / 2;
trackBar1.Value = int.Parse(Math.Ceiling(Decimal.Parse(t2.ToString())).ToString());
trackBar2.Value = trackBar1.Value;
}
private void trackBar1_Scroll(object sender, EventArgs e)
{
label1.Text = trackBar1.Value.ToString();
trackBar2.Value = trackBar1.Maximum - trackBar1.Value;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我也想知道这个问题...
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你现在遇到了什么问题吗?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询