Where to use?
When there
is a need to enable/disable particular menu we can use this code.
Control: ContextMenuStrip
( Name : cmsQA)
Event: ( Opening)
Code :
private void cmsQA_Opening(object
sender, CancelEventArgs e)
{
try
{
e.Cancel =
!(lsvFiles.SelectedItems.Count > 0);
if
(lsvFiles.SelectedItems.Count == 1)
{
cmsAllocation.Items["tsmAssignFile"].Enabled = false;
cmsAllocation.Items["tsmUpload"].Enabled = false;
cmsAllocation.Items["tsmChangeTemplate"].Enabled = false;
cmsAllocation.Items["tsmDelete"].Enabled = false;
int iIndex = 5;
int[]
iAssigneFileStatus = new int[] { 1, 5, 9 };
if
(iAssigneFileStatus.Contains(iIndex))
{
cmsAllocation.Items["tsmAssignFile"].Enabled = true;
}
}
}
catch
(Exception ex)
{
ExceptionHandler.HandleException(ex.ToString());
}
}
No comments:
Post a Comment