I have a custom listbox that inherits the WinForms ListBox
class, like so.
public class UserListBox : ListBox
{
protected override void OnPaint(PaintEventArgs e)
{
// Omitted for brevity...
}
}
I add a filter on this ListBox
(just like GridView
control's DefaultView) but when I change the items, the OnPaint method is called regardless. I cannot call other method like remove.
I test SendMessage WM_SETREDRAW to suspend update, but that isn't working.
How can I suspend the call to the OnPaint
method?
答案 0 :(得分:0)
Original
I'm not sure why you would ever want to actually do this, but it is possible. With WinForms
you can actually P/Invoke into some native calls and attempt to manage things like the windows messaging loop. In all honesty, I would suggest trying to avoid doing this. What is it that you're trying to accomplish?
How can I suspend the Control.OnPaint method?
Follow this link to check out an example.
Update
According to the MSDN documentation, you're doing it correctly. Could you please provide some more source code such that I could have another look?