When populating a listview it is always a good idea to call BeginUpdate before adding/removing/clearing items. Otherwise the control will attempt to repaint on every change, greatly reducing the overall performance.
A question often asked is what to do with Listbox and Combobox classes, which in Compact Framework do not expose these methods. Apparently it is quite easy to emulate missing methods.
The secret is in WM_SETREDRAW message. It tells the window to stop updating itself. The actual implementation is up to the window class, but luckily in case of Combobox and Listbox this message is handled and provides expected results. Here is what is says in remarks part of the message description:
The window manager provides no default processing for this message. However, certain controls do support this message, list box, tree view, and combo box
Armed with this knowledge, we find it almost trivial to write the missing methods:
public class UIHelper{ public static IntPtr GetHandle(Control ctl) { ctl.Capture = true; IntPtr ret = Win32Window.GetCapture(); ctl.Capture = false; return ret; }
IntPtr hWnd = GetHandle(ctl); Win32Window.SendMessage(hWnd, WM_SETREDRAW, bDisable? 0: 1, 0); }
const int WM_SETREDRAW = 0x0b;}
Notice
Remember Me
Powered by: newtelligence dasBlog 1.8.5223.2
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.
© Copyright 2010, Alex Feinman