Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to bind listview/datagridview without refreshing control temporarily

Posted on 2007-08-10
9
Medium Priority
?
2,014 Views
Last Modified: 2013-11-07
Hi experts

i have some datagridview and listview to bind from database and i have some routines that add row in  a for each loop...

so to add some boost in the routine, i would like to stop refreshing the control while the control is binding :

i meant something like this :

me.datagridview.suspendlayout
for each r as datarow in datatable.rows
'process and add row to datagridview dynamically
next
me.datagridview.resumelayout

so the datagridview displays only the new result at the end of the process

is it possible?

regards
0
Comment
Question by:Dnx_7
  • 3
  • 3
6 Comments
 
LVL 48

Expert Comment

by:jpaulino
ID: 19670116
But you can do, whats the problem ?

   Me.DataGridView1.SuspendLayout()
   Me.DataGridView1.ResumeLayout()
0
 
LVL 2

Author Comment

by:Dnx_7
ID: 19670647
what i tried to do is exactly the suspend and resume but it seems that the control is still refreshing :

lvmail = listview

//code

   Me.lvMail.SuspendLayout()
   Me._mailChecker.GetMail() (business logical getting mail in another thread)

the getMail function :

   Dim test As ClsMessage
        For i As Int32 = 0 To 1000
            test = New ClsMessage("message " & i, i.ToString, True, True, Date.Now)
            RaiseEvent AddMessage(Me, test)
        Next
'when finish raise an event to update GUI
        RaiseEvent LoadMailWorkerComplete(Me)


in the gui :

 If Me.InvokeRequired Then
            Me.BeginInvoke(New CommonLibrary.ClsDetailMail.LoadMailWorkerCompleteHandler(AddressOf Me._mailChecker_LoadMailWorkerComplete), New Object() {sender})
        Else
            Me.lvMail.ResumeLayout()
        End If




i still see the control "flickering"

any idea?

regards
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 19670987
Try to suspendlayout of your form

Me.SuspendLayout()
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 2

Author Comment

by:Dnx_7
ID: 19752464
why i cannot only suspend the control?

regards
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 19754050
Normally it's possible, but if the code runs to fast maybe it's better to add some refresh and some pause to your code

Me.lvMail.SuspendLayout()
System.Theading.Thead.Sleep(100)
Application.DoEvents

This should work.

Jorge
0
 
LVL 2

Accepted Solution

by:
Dnx_7 earned 0 total points
ID: 19757605
i found the solution on other post in EE and other links pointed in those solutions...

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_22089821.html?sfQueryTermInfo=1+flicker+suspendlayout
http://www.experts-exchange.com/Programming/Misc/Q_21753659.html

so i conclude that the suspendlayout isn't good for what i want to achieve but "sendMessage" is the right one, i tested and it works very good

thank you for your help but i cannot give the points, sorry.

Kind regards
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month21 days, 5 hours left to enroll

810 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