Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8362279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:54:18+00:00 2026-06-09T11:54:18+00:00

I have two labels for example the first one is: The temperature is now

  • 0

I have two labels for example the first one is:

The temperature is now –

And the second label:

46c

But if sometimes only for the question if the temperature will get hight to 100 so it should be:

The temperature is now – 100c

But then the c of the 100 will get over the “-” of the other label. So if its two digits its ok but if its three digits its getting over the other label.

Is there any way to calculate or to update automatic the label with the numbers so it will change its location according to the number of digits currently it has and according to the other label location so they wont get one over the other one ?

My code in the constructor.

temperature_label = new Label();
    textMode_label = new Label();
    this.Controls.Add(textMode_label);
    this.Controls.Add(temperature_label);

    temperature_label.Location = new Point(260, 200);
    temperature_label.Height = 250;
    temperature_label.Width = 500;
    temperature_label.ForeColor = Color.Red;
    temperature_label.Font = new Font("Arial", 35, FontStyle.Bold);
    temperature_label.Text = "200c";

    textMode_label.Location = new Point(350, 200);
    textMode_label.Height = 250;
    textMode_label.Width = 500;
    textMode_label.ForeColor = Color.Blue;
    textMode_label.Font = new Font("Arial", 35, FontStyle.Bold);
    textMode_label.Text = "The Temperature Now Is - ";

Then in the timer tick event im updating the temperature_label with the values:

private void timer_Tick(object sender, EventArgs e)
        {
            Computer computer = new Computer();
            computer.Open();
            computer.GPUEnabled = true;

            foreach (var hardwareItem in computer.Hardware)
            {

                if (hardwareItem.HardwareType == HardwareType.GpuNvidia)
                {
                    foreach (var sensor in hardwareItem.Sensors)
                    {
                        if (sensor.SensorType == SensorType.Temperature)
                        {
                            sensor.Hardware.Update();

                            temperature_label.Text = sensor.Value.ToString()+ "c";
                            timer.Interval = 1000;
                            if (sensor.Value > 90)
                            {
                                Logger.Write("The current temperature is ===> " + sensor.Value);
                                button1.Enabled = true;
                            }
                            this.Select();
                        }
                    }
                }

            }     
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:54:19+00:00Added an answer on June 9, 2026 at 11:54 am

    You could use a single lable instead of two and do a string.Format on the text.
    Use the Tag-property of the label to hold the text you want to format and, after formatting, assign it as the labels text.

    So something along the line of:

    temperature_label = new Label();
    this.Controls.Add(temperature_label);
    
    temperature_label.Location = new Point(260, 200);
    ...
    temperature_label.Tag = The Temperature Now Is - {0}C;
    temperature_label.Text = "Fetching temperature...";
    

    and then in the inner-loop of your tick-handler:

    ....
    
    temperature_label.Text = string.Format(temperature_label.Tag, sensor.Value);
    
    ....      
    

    This only works if there is no need to right align the temperature value, though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two list one with the label and the other data. for example
I have two textboxes with calendarextender and One Label. The first textbox represents the
I'm using jQuery validation plugin. I have two images: first background of label, when
Have two actionsheet buttons and one modalviewcontroller on mainviewcontroller in application. Now for two
Here I have a two files. One for forms and second php for getting
I have two div's: <div><label for=1>Some really loooong text... Which breaks the second div.
I have two labels (A and B) in a Flex VBox, with the horizontal
I have two labels that are stacked. If I want a horizontal line between
For Android I have two labels in a table row. I am trying to
I've created a skin that allows me to have two labels on a spark

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.