Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

VB.Net - Loop putting Data in a Label or Textbox

Posted on 2013-05-29
2
435 Views
Last Modified: 2013-05-29
Good Day Experts!

I have a longer running Select statement that I display in a DataGridView.  It runs for a "while" so I want to keep the User company by displaying data from each record in a label or textbox on the form.  However, that is not the problem I am faced with.  Issue is I can't get the data to show in the control!  

Here is what I have:

Dim AccountNumber As String = rdrGetAccountNumbers.Item("Account Number")
lblAccountIC.Text = AccountNumber
txtAcctNum.Text = AccountNumber

When stepping through the code and I hover over lblAccountIC.Text  and  txtAcctNum.Text the data is there...it just isn't showing on the screen.  

I am probably totally missing something very simple, but what do you think?

Thanks,
jimbo99999
0
Comment
Question by:Jimbo99999
2 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 125 total points
ID: 39205265
It's not showing (most likely) because you are running this logic on the main thread of your application...which just happens to be the same thread that all GUI actions occur on. You are basically locking up your GUI until the loop finishes.

As a quick-and-dirty fix, you can add a Applications.DoEvents() call within your loop code.

e.g.

For i As Integer = 0 To SomeUpperBound
    ' Some processing logic

    Application.DoEvents()
Next

Open in new window


This should allow the GUI to update itself while the loop is running. The more preferred way would be to use a BackgroundWorker or a separate thread to run the loop logic, passing message back to the GUI thread that can be used to display on your form.
0
 

Author Comment

by:Jimbo99999
ID: 39205508
That is awesome...I never knew that and it makes sense now.  I will read up on the BackgroundWorker and seperate thread idea.

Thanks for the help,
jimbo99999
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question