Hi,
Suppose we have ContextMenuStrip defined for the UltraGrid. There are 3 menuitems(menu1, menu2, menu3) in ContextMenuStrip.
In .Open event of ContextStripMenu we make Visible property of all 3 buttons False. Then on First right click of mouse we see a narrow line.
Can you please suggest how to overcome it? I don't want to see anything if for all items in menustrip Visible = False.
Hello Nitin,Thank you for contacting Infragistics!Please see the sample I am sending you attached to this email. In the handler of ContextMenuStrip Opening Event I am checking if all items in the ContextMenuStrip are equal to false, then the event is being canceled.This is one of the ways to prevent the rendering of empty ContextMenuStrip and its narrow line.I am looking forward for your answer.
Hi Ivaylo,
I went through your solution. I find that in .Open event of Ultragrid the value we get for toolstripmenuitem.Visible does not show the real value.
It is always showing value as false irrespective of setting it to true. If it showed the real values then I can check it and cancel the event. But, since it is not happening, the event will always be cancelled.
Thanks,
Nitin
I am not able to check Visible property of toolstripmenuitem in .Opening event.
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e){ toolStripMenuItem1.Visible = true;
if (toolStripMenuItem1.Visible == true) { e.Cancel = true; } }
Here, after setting toolStripMenuITem.Visible = true;
If we check value of toolStripMenuITem.Visible, it is showing false. Is there any other event which I can use instead of .Opening?
Hello Nitin,
Could you please let me know the if you been able to find in your application the part of code which is responsible to set visible properties of ToolStripItem. Could you please post this part of code. Also I am posting you snippet which describes what way I found for you to filter the ToolStripItems.
I am waiting for your feedback.
I have a simple case where I check <Condition> and depending upon that either show all the toolstripitem or nothing at all.
So if the your condition is evaluated to be true and you should hide all toolstipItems, then you should cancel the event, so you should use code like:
If Then toolStripItem2.Visible = False toolStripItem1.Visible = False e.Cancel = True
Else
toolStripItem2.Visible = True toolStripItem2.Visible = True
End If
Also ContextMenuStrip is a standard Microsoft component, and I have tested your scenario with the standard Microsoft DataGridView component and the behavior is the same. So based on this I could conclude that the issue is not specific to Infragistics components, and I believe that more accurate answers about how exactly ContextMenuStrip you will find in Microsoft Support Department.
Please let me know if you have any further questions related to Infragistics components.
Thank you for your support over this issue.
Regards,