user1544479
user1544479

Reputation: 1017

How can i make the label to blink change colors but only around the lable it self?

I have two labels in the designer:

Both are sized: 410(width),55 Location: 340(X),100. Under each label, I have a small label very colse to it: size: 69,17

Then I have two labels in the runtime code, each of which is left of the other two labels, and each one shows a value.

private void GPULabels()
        {
            
                

                GpuTemperature_label.Location = new Point(250, 100);
                GpuTemperature_label.Height = 250;
                GpuTemperature_label.Width = 500;
                GpuTemperature_label.ForeColor = Color.Red;
                GpuTemperature_label.Font = new Font("Arial", 35, FontStyle.Bold);
                button3.Enabled = false;
            
        }

        private void CPULabels()
        {
            CpuTemperature_label.Location = new Point(250, 200);
            CpuTemperature_label.Height = 250;
            CpuTemperature_label.Width = 500;
            CpuTemperature_label.ForeColor = Color.Red;
            CpuTemperature_label.Font = new Font("Arial", 35, FontStyle.Bold);

           
        }

I want to make the following two labels blink: GPULabels and CPULabels.

The Form1 size is: 800x600

I created a condition that if X > Y then blink:

private void blinking_label()
        {
            if (GpuTemperature_label.BackColor == SystemColors.Control)
            {
                GpuTemperature_label.BackColor = Color.Blue;
            }
            else
                if (GpuTemperature_label.BackColor == Color.Blue)
                {
                    GpuTemperature_label.BackColor = SystemColors.Control;
                }

        }

The result when its blinking is:

enter image description here

And I want only the value to blink on the label on the left which contains the value (in this case 46), but I only want the 46 to blink! The label that contains the value in this case in the image is GPULabels(), the GpuTemperature_label.

But instead, as the mage show the blinking paint a lot of area.

Upvotes: 1

Views: 935

Answers (1)

Piyush
Piyush

Reputation: 26

Your both the labels i.e. the one you are creating in the code and the one that you must have declared in the designer are overlapping. Try to readjust the width and the position of the GpuTemperature_label as per your requirement.

What I can suggest that change the width property of the GpuTemperature_label to 200 and its location to 140,100.

Going by the name of your label I guess you are trying to display the temperature and the value will never be more than 2 digits hence, you don't need its width to be 500px.

Alternatively, if you still can't change the position of the labels owing to your design obligation, then keep the Position Y of both the labels to 100 (or whatever suits your application) and make their height equal. In that way your second label will completely overlap the GpuTemperature_label thereby engulfing those incomplete lines that are appearing now.

Upvotes: 1

Related Questions