Update LabelControl

This is a discussion on Update LabelControl within the C# Programming forums, part of the General Programming Boards category; I will read a .txt-file "DGD.txt" 49 times. To keep track of that I use a foor-loop for the count. ...

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    383

    Update LabelControl

    I will read a .txt-file "DGD.txt" 49 times. To keep track of that I use a foor-loop for the count. Inside the foor-loop I have a while-loop that read this file.

    For every count I will put a text to a Label1 like this:
    Code:
    Label1->Text = "Display this";
    So this meens that before reading the file in the whilestatement this should be displayed in the Label1 Box and also be rewritten the other 48 counts(This Text will change later but this is a test)

    However what happens is that the text "Display this" i put to the Label1 first when count is at 49.
    Why is this happening. I want it to update for every loop, in this case 49 times.
    Any idéas to this. I dont know If I need to use (WM_PAINT) in any way here ?

    Code:
    std::string Line;
    ofstream MainFile;
    MainFile.open ("Main.txt");
    
    
    	for (int count= 1; count < (50); count++)
    	{ 
    		
    		Label1->Text = "Display this";
                    Label1->Invalidate();
    				
    	
    		ifstream File ("File1.txt");
    		while	(    getline(File, Line, '\n')  )           		
    		{
    		
    			MainFile << "Hello" << ',' << "Hello2" << '\n';
    
    		}
    
    
    	}
    If I would put this messagebox inside the for-loop this will "Display this" 49 times as a comparison.
    Code:
    MessageBox::Show("Display this");
    Last edited by Coding; 02-22-2008 at 04:47 PM.

  2. #2
    Registered User AloneInTheDark's Avatar
    Join Date
    Feb 2008
    Posts
    74
    hm maybe this?
    Code:
    Label1.Text = "Display this " + count.ToString();
    Application.DoEvents();
    I didn't get your question too well.

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    383
    Yes. This did work great. Only to add "Application:: DoEvents()" worked great here.
    Last edited by Coding; 02-23-2008 at 08:10 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Polymorphism; Update functions and accessibility
    By CaptainMaxxPow in forum C# Programming
    Replies: 2
    Last Post: 04-23-2009, 09:48 AM
  2. SQLite not performing update
    By OnionKnight in forum C Programming
    Replies: 0
    Last Post: 01-21-2009, 04:21 PM
  3. OpenGL Color update problem
    By arifin in forum C++ Programming
    Replies: 0
    Last Post: 07-22-2008, 01:17 AM
  4. July 9 2008 MS XP Update
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 07-18-2008, 06:14 AM
  5. ListView Refresh, Update
    By de4th in forum C++ Programming
    Replies: 1
    Last Post: 12-23-2006, 09:13 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21