Slider colors not updating.

DK_582

New member
Joined
Mar 7, 2021
Messages
3
Programming Experience
Beginner
So I want to have an Rainbow Color Gradient option in my application. Everything else changes its color except the sliders. They only update the color when I change their value. Is there any way to fix it? A code or something?
Here is a short GIF of my problem: Gyazo
 
If it's not working then you did it wrong. As you decided not to show us what you did, we can't tell you what's wrong with it.
It's working flawlessly on sliders from different frameworks, so I don't think I am doing something wrong. This is the code I am using:
C#:
int r = 244;
int g = 65;
int b = 65;

private void Rr_Tick(object sender, EventArgs e)
        {
            if (b >= 244)
            {
                r -= 1;
                siticoneCustomCheckBox1.CheckedState.FillColor = Color.FromArgb(r, g, b);
                flatTrackBar1.ColorScheme1 = Color.FromArgb(r, g, b); flatTrackBar1.ColorScheme2 = Color.FromArgb(r, g, b);
                flatTrackBar2.ColorScheme1 = Color.FromArgb(r, g, b); flatTrackBar2.ColorScheme2 = Color.FromArgb(r, g, b);
                if (r <= 65)
                {
                    Rr.Stop();
                    Gg.Start();
                }
            }

            if (b <= 65)
            {
                r += 1;
                siticoneCustomCheckBox1.CheckedState.FillColor = Color.FromArgb(r, g, b);
                flatTrackBar1.ColorScheme1 = Color.FromArgb(r, g, b); flatTrackBar1.ColorScheme2 = Color.FromArgb(r, g, b);
                flatTrackBar2.ColorScheme1 = Color.FromArgb(r, g, b); flatTrackBar2.ColorScheme2 = Color.FromArgb(r, g, b);
                if (r >= 244)
                {
                    Rr.Stop();
                    Gg.Start();
                }
            }
        }

        private void Gg_Tick(object sender, EventArgs e)
        {
            if (r <= 65)
            {
                g += 1;
                siticoneCustomCheckBox1.CheckedState.FillColor = Color.FromArgb(r, g, b);
                flatTrackBar1.ColorScheme1 = Color.FromArgb(r, g, b); flatTrackBar1.ColorScheme2 = Color.FromArgb(r, g, b);
                flatTrackBar2.ColorScheme1 = Color.FromArgb(r, g, b); flatTrackBar2.ColorScheme2 = Color.FromArgb(r, g, b);
                if (g >= 244)
                {
                    Gg.Stop();
                    Bb.Start();
                }
            }

            if (r >= 244)
            {
                g -= 1;
                siticoneCustomCheckBox1.CheckedState.FillColor = Color.FromArgb(r, g, b);
                flatTrackBar1.ColorScheme1 = Color.FromArgb(r, g, b); flatTrackBar1.ColorScheme2 = Color.FromArgb(r, g, b);
                flatTrackBar2.ColorScheme1 = Color.FromArgb(r, g, b); flatTrackBar2.ColorScheme2 = Color.FromArgb(r, g, b);
                if (g <= 65)
                {
                    Gg.Stop();
                    Bb.Start();
                }
            }
        }
 
Set breakpoints on your tick events. Are they even being called? Did you start the timer(s)? If you did start the timer(s), did you register your tick event handlers?
 
I don't think I am doing something wrong.
If you have code to do something and it's not done then assume that you did something wrong. Almost invariably, that assumption will be correct but, on the rare occasions that it's not, proper investigation for what you did wrong will reveal that. That proper investigation involves debugging with breakpoints, to ensure that the path of execution is what you expect and variables and other key expressions evaluate as expected along the way.
 

Latest posts

Back
Top Bottom