Reputation: 8214
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.
Thus no item is ever checked when the usercontrol is m_locked
.
Is there a way to solve this without changing how the listview is populated?
Upvotes: 2
Views: 1125
Reputation: 47510
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.
Upvotes: 2