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?
Even though you call that method in the parent form_load that effectively fires when you select that tab. Set
m_loadingto false after user control loads, which will not occur until you select that tab.