Winforms ListView ItemCheck on load
I have a winform containing tabs, containing a usercontrol, containing a listview with checkboxes.
private void lvwRoles_ItemCheck(object sender, System.Windows.Forms.ItemCheckEventArgs e)
{
if (!m_loading && m_locked)
{
e.NewValue = e.CurrentValue;
return;
}
The listview is assigned it's items (some is checked) in a method (in the user control) that is called from the parent form. This is done on load of the parent form.
My problem is that the ItemCheck
occurs when 开发者_运维百科I click the corresponding tab the first time.
That results in the m_loading
state variable being false since long ago.
m_locked
.
Is there a way to solve this without changing how the listview is populated?
The listview is assigned it's items (some is checked) in a method (in the user control) that is called from the parent form. This is done on load of the parent form.
Even though you call that method in the parent form_load that effectively fires when you select that tab. Set m_loading
to false after user control loads, which will not occur until you select that tab.
精彩评论