C# trackBar1 加 toolTip1 +comboBox1
效果:
移動 trackBar 要show 頁數 也要變更 comboBox 的值 滑鼠 拖動不動 放開才改
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.SelectedItem != null)
{
string curItem = comboBox1.SelectedItem.ToString();
int i = comboBox1.SelectedIndex;
//值樹問題 數值才會對上
int page_n = i + 1;
trackBar1.Maximum = comboBox1.Items.Count ;
this.Text = page_n + "/" + trackBar1.Maximum;
trackBar1.Value = i;
}
}
bool trac_mouse_down = false;//設一個滑鼠是按下旗標
private void trackBar1_Scroll(object sender, EventArgs e)
{
//設定 顯示文字 這邊跟 ValueChanged 感覺是相同的 但是如果是 在一起處理 又設字 又改數值
//comborbox 好像會定在那邊 分開處理就沒事了
toolTip1.SetToolTip(trackBar1, (trackBar1.Value + 1) + @"/" + trackBar1.Maximum + "頁");
}
private void trackBar1_ValueChanged(object sender, EventArgs e)
{
if(trac_mouse_down==false)
comboBox1.SelectedIndex = trackBar1.Value;
}
private void trackBar1_MouseUp(object sender, MouseEventArgs e)
{
trac_mouse_down = false;
comboBox1.SelectedIndex = trackBar1.Value;
}
private void trackBar1_MouseDown(object sender, MouseEventArgs e)
{
trac_mouse_down = true;
}
移動 trackBar 要show 頁數 也要變更 comboBox 的值 滑鼠 拖動不動 放開才改
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.SelectedItem != null)
{
string curItem = comboBox1.SelectedItem.ToString();
int i = comboBox1.SelectedIndex;
//值樹問題 數值才會對上
int page_n = i + 1;
trackBar1.Maximum = comboBox1.Items.Count ;
this.Text = page_n + "/" + trackBar1.Maximum;
trackBar1.Value = i;
}
}
bool trac_mouse_down = false;//設一個滑鼠是按下旗標
private void trackBar1_Scroll(object sender, EventArgs e)
{
//設定 顯示文字 這邊跟 ValueChanged 感覺是相同的 但是如果是 在一起處理 又設字 又改數值
//comborbox 好像會定在那邊 分開處理就沒事了
}
private void trackBar1_ValueChanged(object sender, EventArgs e)
{
if(trac_mouse_down==false)
comboBox1.SelectedIndex = trackBar1.Value;
}
private void trackBar1_MouseUp(object sender, MouseEventArgs e)
{
trac_mouse_down = false;
comboBox1.SelectedIndex = trackBar1.Value;
}
private void trackBar1_MouseDown(object sender, MouseEventArgs e)
{
trac_mouse_down = true;
}
留言
張貼留言