Write on a label when it loads with the form

2

Well, I have a program that requires me to write using labels, but these only work, and actually write when they are clicked, I would like someone to explain how I should proceed to be able to write then the form is loaded :

EDIT: Basically as I said I'm trying to write in a label data that I took out of a DB, but this is only written when I click on the labels, I'd like it to be written as soon as the form and about or loaded, / p>

SqlConnection conn = new SqlConnection(@"Data Source=.\wintouch;Initial        Catalog=bbl;User ID=sa;Password=Pa$$w0rd");
    conn.Open();
    string info = ""; // open connection and creat the string that contains info



        //-----------------------------------------------------------//

        Timer timer1 = new Timer();

        timer1.Tick += new EventHandler(label4_load);
        timer1.Interval = 55;
        timer1.Enabled = true;


        string varsql = "SELECT sum(merc1)/2 as total FROM wgcdoccab where tipodoc ='FSS' and serie='1' and contribuinte='999999990' and  datadoc = CONVERT(varchar(10),(dateadd(dd, -1, getdate())),120)"; //division query 


        SqlCommand cmd = new SqlCommand(varsql, conn);

        SqlDataReader dr = cmd.ExecuteReader();

        while (dr.Read())
        {

            info = dr["total"].ToString().TrimEnd() + "," + "\r"; // search the database?

        }

        label4.Text = info; //display information on hte label
        label4.Text = string.Format("new_text {0}", DateTime.Now.ToLongTimeString()); 
        conn.Close();

        timer1.Stop();
    }'
    
asked by anonymous 20.07.2015 / 16:44

1 answer

0

When you create a Form, the system creates a constructor like this:

.....
public Form1()
{
   InitializeComponent();
   label1.Text = "Escreva o que tu quiseres aqui";// Faça isso em baixo do InitializeComponent();
}

That's all and nothing else.

    
20.07.2015 / 18:16