Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Im new to c# and im building a windows form for the Modified early warning scoring system (MEWS) which is used in hospitals to monitor a patients health. I have built a GUI for it, but im not sure what code to put in to get it to work. Im using timers to move coloured labels across the screen to represent a patient vital signs.

Ive but a button in which starts the timers and this works fine. But what I want to do next is show a score based on the output of that vital sign timer. I want to use buttons which when pressed will display the score in a text box. What I want to know is what code do i use to make this work? Also can you give me example code since I will most likely not know how to write it out myself.

Heres the code for my program so far:

C#
namespace MewsV1._0
{
    public partial class frmMews : Form
    {

        Random r = new Random();

        public frmMews()
        {
            InitializeComponent();
        }

        private void txtPatientName_TextChanged(object sender, EventArgs e)
        {

        }

        private void frmMews_Load(object sender, EventArgs e)
        {
            tmrResps.Enabled = false;
            tmrResps.Interval = 300;  // milliseconds

            tmrHeart.Enabled = false;
            tmrHeart.Interval = 700;  // milliseconds

            tmrBlood.Enabled = false;
            tmrBlood.Interval = 700;  // milliseconds

            tmrConsious.Enabled = false;
            tmrConsious.Interval = 600;  // milliseconds

            tmrTemp.Enabled = false;
            tmrTemp.Interval = 600;  // milliseconds

            tmrUrine.Enabled = false;
            tmrUrine.Interval = 600;  // milliseconds

        }

        private void btnStart_Click(object sender, EventArgs e)
        {
            tmrResps.Enabled = true;
            tmrResps.Interval = 2000;  // milliseconds

            tmrHeart.Enabled = true;
            tmrHeart.Interval = 1000;  // milliseconds

            tmrBlood.Enabled = true;
            tmrBlood.Interval = 2000;  // milliseconds

            tmrConsious.Enabled = true;
            tmrConsious.Interval = 5000;  // milliseconds

            tmrTemp.Enabled = true;
            tmrTemp.Interval = 1000;  // milliseconds

            tmrUrine.Enabled = true;
            tmrUrine.Interval = 5000;  // milliseconds
        }

        private void tmrResps_Tick(object sender, EventArgs e)
        {
            Random r = new Random();

            int x = ( (int)( (r.Next(0, 100) ) / 10) ) * 10;

            //---

            if (lblResps.BackColor == System.Drawing.Color.Magenta)
            {
                lblResps.BackColor = System.Drawing.Color.Magenta;
                lblResps.Size = new System.Drawing.Size( x, 23);
            }
            else
            {
                lblResps.BackColor = System.Drawing.Color.Magenta;
            }

        }

        private void tmrHeart_Tick(object sender, EventArgs e)
        {
            int x = ((int)((r.Next(0, 100)) / 10)) * 10;

            if (lblHeart.BackColor == System.Drawing.Color.Cyan)
            {
                lblHeart.BackColor = System.Drawing.Color.Cyan;
                lblHeart.Size = new System.Drawing.Size(x, 23);
            }
            else
            {
                lblHeart.BackColor = System.Drawing.Color.Cyan;
            }
        }

        private void tmrBlood_Tick(object sender, EventArgs e)
        {
            int x = ((int)((r.Next(0, 100)) / 10)) * 10;


            if (lblBlood.BackColor == System.Drawing.Color.Red)
            {
                lblBlood.BackColor = System.Drawing.Color.Red;
                lblBlood.Size = new System.Drawing.Size(x, 23);
            }
            else
            {
                lblBlood.BackColor = System.Drawing.Color.Red;
            }

        }

        private void tmrConsious_Tick(object sender, EventArgs e)
        {
            int x = ((int)((r.Next(0, 100)) / 10)) * 10;

            if (lblConsious.BackColor == System.Drawing.Color.Green)
            {
                lblConsious.BackColor = System.Drawing.Color.Green;
                lblConsious.Size = new System.Drawing.Size(x, 23);
            }
            else
            {
                lblConsious.BackColor = System.Drawing.Color.Green;
            }

        }

        private void tmrTemp_Tick(object sender, EventArgs e)
        {
            int x = ((int)((r.Next(0, 100)) / 10)) * 10;

            if (lblTemp.BackColor == System.Drawing.Color.Brown)
            {
                lblTemp.BackColor = System.Drawing.Color.Brown;
                lblTemp.Size = new System.Drawing.Size(x, 23);
            }
            else
            {
                lblTemp.BackColor = System.Drawing.Color.Brown;
            }
        }

        private void tmrUrine_Tick(object sender, EventArgs e)
        {
            int x = ((int)((r.Next(0, 100)) / 10)) * 10;

            if (lblUrine.BackColor == System.Drawing.Color.Yellow)
            {
                lblUrine.BackColor = System.Drawing.Color.Yellow;
                lblUrine.Size = new System.Drawing.Size(x, 23);

            }
            else
            {
                lblUrine.BackColor = System.Drawing.Color.Yellow;
            }
      }
    }
}
}


Random Number code im using:

C#
namespace RandomNumber
{
    class Program
    {
        static void Main(string[] args)
        {
            Random r = new Random();

            for (int i = 0; i < 500; i++)
            {
                int x = ( (int)( ( r.Next(0, 100) ) / 10 ) ) * 10;

                Console.WriteLine(x.ToString());
            }
        }
    }
}
Posted

1 solution

in the button's click event, assign the text box's text method to the value you want it to display for example:

textbox1.Text = "item you want to display"
 
Share this answer
 
Comments
programmer1234 4-Dec-10 18:20pm    
Yes that Worked, thanks for your help.
[no name] 4-Dec-10 18:25pm    
you welcome

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900