none
How to show icons of mute button and unmute button when trackbar1 control value set? RRS feed

  • Question

  • Hi,

    I'm designing a windows app with c# programming language

    This app is about media player, i have two buttons with images one of them for mute and the other for unmute and i have a track bar control.

    I want to show the mute button icon when the track bar value equal 0, and show the unmute button icon when the track bar equal 10.

    please, if where everyone knows how tell me

    Thank, you

    Tuesday, February 5, 2019 3:08 PM

Answers

  • Hi Joe Kros,

    Thank you for posting here.

    For your question, you could try the code below.

    using System;
    using System.Windows.Forms;
    
    namespace WindowsForms
    {
    
        public partial class Test : Form
        {
    
            public Test()
            {
                InitializeComponent();
            }
            private void Test_Load(object sender, EventArgs e)
            {
                trackBar1.Minimum = 0;
                trackBar1.Maximum = 10;
                trackBar1.Value = 5;
                btnMute.Visible = false;
                btnUnMute.Visible = false;
            }
    
            private void trackBar1_ValueChanged(object sender, EventArgs e)
            {
                if (trackBar1.Value == 0)
                {
                    btnMute.Visible = true;
                    btnUnMute.Visible = false;
                }
                else if (trackBar1.Value == 10)
                {
                    btnUnMute.Visible = true;
                    btnMute.Visible = false;
                }
            }
        }
    }
    
    
    
    

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Joe Kros Wednesday, February 6, 2019 7:55 AM
    Wednesday, February 6, 2019 2:20 AM
    Moderator

All replies

  • Hi Joe Kros,

    Thank you for posting here.

    For your question, you could try the code below.

    using System;
    using System.Windows.Forms;
    
    namespace WindowsForms
    {
    
        public partial class Test : Form
        {
    
            public Test()
            {
                InitializeComponent();
            }
            private void Test_Load(object sender, EventArgs e)
            {
                trackBar1.Minimum = 0;
                trackBar1.Maximum = 10;
                trackBar1.Value = 5;
                btnMute.Visible = false;
                btnUnMute.Visible = false;
            }
    
            private void trackBar1_ValueChanged(object sender, EventArgs e)
            {
                if (trackBar1.Value == 0)
                {
                    btnMute.Visible = true;
                    btnUnMute.Visible = false;
                }
                else if (trackBar1.Value == 10)
                {
                    btnUnMute.Visible = true;
                    btnMute.Visible = false;
                }
            }
        }
    }
    
    
    
    

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Joe Kros Wednesday, February 6, 2019 7:55 AM
    Wednesday, February 6, 2019 2:20 AM
    Moderator
  • Thank you very much, it's worked perfectly, it's wonderful

    Wednesday, February 6, 2019 7:57 AM