How to set values for Labels through another class

  • 13 years ago

    Hello all,

    I am working with elevator problem in C#.net.....am having a small problem

    i have an ElevatorForm class which contains the GUI part i.e., all labels and buttonss...so on....

    am having another class ElevatorLabel in which we are assinging values to lables as below snippet of code...in ElevatorLabel am creating an object for Elevator class as shown below

    ElevatorForm Efrm=new ElevatorForm();

    for(int i=0;i<5;i++)

    {

    Efrm.label1.Text = i.ToString();                     //Assingning value to label

    } but it is displaying the last value i.e., 4...i want to dispaly likw 0 ,1,2,3,4 ..plz suggest me with an solution

    thanking u

     

  • 13 years ago

    ElevatorForm Efrm=new ElevatorForm();

    string text = String.Empty;
    for (int i = 0; i < 5; i++)
    {
      text += i.ToString();
      text += ",";
    }
    Efrm.label1.Text = text.Substring(0, text.Length - 1);  

    Joe 

  • 13 years ago

    Sorry Joe... i didnt gave the question clearly

    i dont want output like 1,2,3,4.......

    i want output like, first it should display 1 in the label text and after some time i.e.,(500ms) again 2 ana again 3.....

    if u plz suggest me with a solution....

    thank

     

  • 13 years ago

    My suggestion would be to use the timer:

    Good example here: http://www.csharphelp.com/archives/archive90.html

     Adjust the code to suit (using the timer event).

    Joe 


Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The greatest performance improvement of all is when a system goes from not-working to working.” - John Ousterhout