Click here to Skip to main content
15,894,740 members
Home / Discussions / C#
   

C#

 
GeneralCustom draw Treeview Control Pin
MrJJKoolJ12-Dec-03 16:02
MrJJKoolJ12-Dec-03 16:02 
GeneralRe: Custom draw Treeview Control Pin
eggie512-Dec-03 18:17
eggie512-Dec-03 18:17 
GeneralRe: Custom draw Treeview Control Pin
Alex Korchemniy13-Dec-03 13:49
Alex Korchemniy13-Dec-03 13:49 
GeneralRe: Custom draw Treeview Control Pin
eggie513-Dec-03 14:52
eggie513-Dec-03 14:52 
GeneralC# control hosed in ActiveX: no tabbing Pin
thedex12-Dec-03 11:31
thedex12-Dec-03 11:31 
GeneralRe: C# control hosed in ActiveX: no tabbing Pin
Heath Stewart12-Dec-03 12:01
protectorHeath Stewart12-Dec-03 12:01 
GeneralListView BeginUpdate not working Pin
Darryl Borden12-Dec-03 11:28
Darryl Borden12-Dec-03 11:28 
GeneralRe: ListView BeginUpdate not working Pin
Heath Stewart12-Dec-03 11:40
protectorHeath Stewart12-Dec-03 11:40 
This is happening because, while the control is not visible, the Windows handle is not created. When the Windows handle is not created, no sorting (and a few other things) is done. If the control is visible - even if it isn't currently painting items - it sorts with each addition to the Items collection!

Even using the LockWindowsUpdate API won't do anything to resolve this issue. The BeginUpdate and EndUpdate methods essentially do the same thing. They disable and enable drawing (respectively) by using the WM_SETREDRAW message. While it isn't documented, LockWindowsUpdate probably does this very same thing.

So, you'll either have to bite the bullet and accept the lag, or hide your control and reshow it when you're finished, but that might be annoying to the user. If nothing else, show a progress bar (so add the items in a separate thread, but be sure to use InvokeRequired and Invoke to actually add the items!) while you're adding items to the user knows that something's happening and that they should way. You should also use a try-finally block to show the wait cursor (Cursor.Current = Cursors.WaitCursor) and, in the finally block, set it back to the default (Cursor.Current = Cursors.Default).

 

-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
GeneralOutloog slidemenu control in C# Pin
naxos12-Dec-03 10:36
naxos12-Dec-03 10:36 
GeneralRe: Outloog slidemenu control in C# Pin
Heath Stewart12-Dec-03 11:31
protectorHeath Stewart12-Dec-03 11:31 
GeneralRe: Outloog slidemenu control in C# Pin
Luis Alonso Ramos13-Dec-03 21:53
Luis Alonso Ramos13-Dec-03 21:53 
GeneralProblem with ListBox heights Pin
blakeb_112-Dec-03 6:35
blakeb_112-Dec-03 6:35 
GeneralRe: Problem with ListBox heights Pin
leppie12-Dec-03 6:39
leppie12-Dec-03 6:39 
GeneralComboBox Pin
Gary Kirkham12-Dec-03 5:32
Gary Kirkham12-Dec-03 5:32 
GeneralRe: ComboBox Pin
Heath Stewart12-Dec-03 9:35
protectorHeath Stewart12-Dec-03 9:35 
GeneralRe: ComboBox Pin
Gary Kirkham12-Dec-03 9:53
Gary Kirkham12-Dec-03 9:53 
GeneralRe: ComboBox Pin
Heath Stewart12-Dec-03 10:06
protectorHeath Stewart12-Dec-03 10:06 
GeneralRe: ComboBox Pin
Gary Kirkham12-Dec-03 10:45
Gary Kirkham12-Dec-03 10:45 
GeneralProblem with .Net Framework bootstrap program rebooting the system in Win 98 Pin
blakeb_112-Dec-03 5:24
blakeb_112-Dec-03 5:24 
GeneralRe: Problem with .Net Framework bootstrap program rebooting the system in Win 98 Pin
Heath Stewart12-Dec-03 9:32
protectorHeath Stewart12-Dec-03 9:32 
GeneralAssembly fails to load Pin
Le centriste12-Dec-03 5:06
Le centriste12-Dec-03 5:06 
GeneralRe: Assembly fails to load Pin
Heath Stewart12-Dec-03 9:29
protectorHeath Stewart12-Dec-03 9:29 
GeneralRe: Assembly fails to load Pin
Eric Gunnerson (msft)12-Dec-03 13:30
Eric Gunnerson (msft)12-Dec-03 13:30 
GeneralDetermining the location of a DragDrop External to a form Pin
Tristan Rhodes12-Dec-03 4:47
Tristan Rhodes12-Dec-03 4:47 
GeneralRe: Determining the location of a DragDrop External to a form Pin
Heath Stewart12-Dec-03 9:19
protectorHeath Stewart12-Dec-03 9:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.