?
Solved

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

Posted on 2013-05-29
2
Medium Priority
?
440 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
[X]
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
2 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

765 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