.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How to make context menu as non selectable when the usercontrol is active

Posted By:      Posted Date: September 08, 2010    Points: 0   Category :Windows Application
I am having a context menu displayed when i right click on a node of a treeview. Suppose my treeview is as follows Root |->some.txt |-> Child(For some.txt) |-> Child1(child for Child) If i right click on Child1 i will have an option as AddNew. If the user selects i will show a user control form for the user displayed in a panel. What i need is if the user selects the option as Child1 and if the user control is active and when the user again right clicks

View Complete Post

More Related Resource Links

In UserControl, FooCmdCanExecute (context menu) not called until after a control button is clicked.


I'm seeing an odd behavior I can't explain.  I am using a 3rd party control, and while it's possible it's an issue with that control, I wanted to inquire here to see if anyone has experienced similar behavior in other instances (unrelated to my particular 3rd party control).

I created a UserControl, comprising a ComponentONE chart and several buttons.  When the UserControl is given a data source (for the chart), it programmatically creates a ContextMenu that allows the user to configure the Y view extent for each of the data series provided in the data source.  After it's created, it's set as the ContextMenu for the chart.  The UserControl is used inside a tab on the app's main window, and is also plunked directly inside another window that can be brought up.

The UserControl defines a RoutedCommand - let's say FooCmd.  When the MenuItems for the context menu are created, their Command properties are set to FooCmd.  Also, a CommandBinding in the UserControl associates FooCmdCanExecute() and FooCmdExecuted() in the control class with the command.

The buttons in the UserControl are for data navigation - e.g. , there's one that moves the chart's "viewport" to the beginning of the data, and one for the "end".  The click handlers are not complex - essentially, they just set

Cutting Edge: Adding a Context Menu to ASP.NET Controls


Although the context menu is a common element of most desktop applications, it is still fairly uncommon in Web application names because it doesn't map well to a server-based technology like ASP. NET.

Dino Esposito

MSDN Magazine February 2005

How to Make CSS for Hyperlinks NOT Affect Menu Items


VWD 2008 Express.

I have the following CSS in my DefaultStyleSheet.css file.  I want this to only apply to text hyperlinks (like links to web sites or email addresses) but NOT to my asp:menu items.  I am finding that although I have defined my asp:menu items in the menu properties, the colors in the text in the menu tabs get overridden by the CSS below.  How can I make this not happen?  Thanks for any help.


{color:#6F928B; text-decoration: none}


{color: #660066;}


Context Menu And Mouse Click Issue

Hello. I am trying to show a context menu at runtime on MouseRightButtonUp, while over a selected image. I also have left mouse button events set up for the selected image. For some reason I cannot get the context menu to show unless I click the left mouse button and while it is held down click the right mouse button and keep it down while I release the left mouse button, followed by releasing the right mouse button. I tested the MouseRightButtonUp event using a simple MessageBox and did not have any problems; it worked as expected when the right mouse button was released. Here is the code: //add behavior for right mouse on this image. img.MouseRightButtonUp += (sender, e) => { //Create Context Menu ContextMenu menu = new ContextMenu(); //img is an Image img.ContextMenu = menu; //Add context menu item MenuItem photoNewWindow = new MenuItem(); photoNewWindow.Header = "Open Original Image"; photoNewWindow.Click += OpenOriginal; //Add menu items to context menu menu.Items.Add(photoNewWindow); //change the current image currentImage = img; }; // add behavior for mouse click on this image. img.MouseLeftButtonUp += (sender, e) => { // left mouse stuff }; Thanks! 

How to add an action to SiteManager's context menu?

How can I add an action to the context menu in "Manage Content and Structure" (sitemanager.aspx)?  I would like to be able to add a "Edit Page" action to the drop-down of pages. We have pages that contain a redirect web part, which redirects the page on load.  We need a way to get into Edit mode to change the redirect URL. Please tell me how I can do this.  Thanks.

Make an item as Non Selectable in WPF - ListBox

Hi All,How to make a list item as non selectable in WPF Listbox?I have a listbox with five items (Normal single column text).(Doesn't have checkbox)My requirement is the user should not  to make Select/Focus the 1st and 4th item in ListBox. (Because that is header of following items)Any suggession/solution?ByRamesh.p Yes! We can!!

Is that possible to make one of the Listboxitems to be not selectable?

I generate listbox items from xml. I need one of the items to be not selectable? Is that possible to achieve it coding only in XAML? Thank you in advance.

Make Menu The Focus When Hovered

I have a menu as per the code below. When a menu item is hovered, the background text on the contentplace holder (body of web page) kind of mixes with the text from the menu items and it messes up the menu text items. It appears that the menu isn't on Focus (I may have the word Focus Incorrect here) and thats why the body text in the contentplaceholder is mixing with the text from the menu items.   <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" ForeColor="Black"                 Font-Size="13pt" Height="32px">      <StaticHoverStyle ForeColor="Blue" BackColor="#E4E4E4" BorderStyle="Outset" />      <DynamicHoverStyle ForeColor="Blue" BackColor="#E4E4E4" BorderStyle="Outset" />      <DynamicMenuStyle BackColor="#E4E4E4" BorderStyle="Solid"/>      <Items>          <asp:MenuItem Text="Home" Value="Home" NavigateUrl="~/Default.aspx"></asp:MenuItem>          <asp:MenuItem Text="Solutions" Value="

Is it possible to disable context menu items based on the selection on Treeview

I will have some sort of nodes for a treeview as follows Root |-> some.txt(A text file which was added at runtime) |->Child(child for some.txt) |-> child1(child for child) I designed my context menu with some options as New and Remove What i need is when i righclick on Root, child or child i would like to disable the Remove option

WPF - strange context menu behaviour



I create contextmenu using that code


 protected MenuItem itemAdd, itemDelete, itemSelectBranch, itemDeleteClasp;
  protected MenuItem itemCut, itemCopy, itemPaste, itemAddParent, itemPasteWithChildren;
  protected MenuItem itemAddTask, itemAddExtTask, itemAddMileStone;
 menu = new ContextMenu();
    itemAdd = new MenuItem
             HorizontalAlignment = HorizontalAlignment.Left,
             HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch,
             Header = "Add"
    itemDelete = new MenuItem
               HorizontalAlignment = HorizontalAlignment.Left,
               HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch,
               Header = "Delete"
    itemSelectBranch = new MenuItem
      HorizontalAlignment = HorizontalAlignment.Left,
      HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch,
                  Header = 

listview with context menu

i have a listview with two groups ... and i have a context menu assigned to that listview. my problem is i dont want to display the context menu in group 2 but it should display on group1 items when i right click my mouse ... how can i do this... 

How to remove 'Delete Item' from context menu of a programmatically created list?

How to remove 'Delete Item' from context menu of a programmatically created list?
I have document library which is created programmatically but now I don't want to have 'Delete Item' in context menu of that document library. Are there any possibilites?

Context menu in sharepoint 2010

How to hide context menu for a list in sharepoint 2010

How do I get a custom context menu to show up???

Okay, I just started back working on my web browser using Visual Basic 2K8, and I want to have my custom context menu show up when the user clicks inside the browser..... This is what I have...
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Browser As New WebBrowser
        TabControl1.TabPages.Add("New Tab")
        Browser.Name = "Web Browser"
        Browser.Dock = DockStyle.Fill
        AddHandler Browser.ProgressChanged, AddressOf Loading
        AddHandler Browser.DocumentCompleted, AddressOf Done
        Int = Int + 1
        CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(UrlLocation.Text)
    End Sub

That is where I suspect the bit of code will have to go... Since I'm using Tab Control instead of the WebBrowser...

Hide context menu except workflows

I have added 3 lists as 3 web parts in a page.I have to hide context menu(View Properties,Edit Properties,Alerts,Workflows,Send To,Manage Permissions,Compliance Details and Delete) except workflows only for 1 webpart for particular users.Please help me out in this regard...It's very urgent.

.NET 4.0: Inside UserControl Menu.Items.Add(...) cause 'HttpException (0x80004005)'


When using .NET 4.0 there seems to be an issue - inside any UserControl Menu.Items.Add(...) cause 'HttpException (0x80004005)':


The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace:

[HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]
   System.Web.UI.ControlCollection.Add(Control child) +11242224
   System.Web.UI.Control.PreRenderRecursiveInternal() +113
   System.Web.UI.Control.PreRenderRecursiveInternal() +222
   System.Web.UI.Control.PreRenderRecursiveInternal() +222

Problem merging toolstrip control placed in UserControl with MDI Form menu


I currently have an MDI application with a MenuStrip as Main Menu. The application has a child form where an instance of one UserControl with a MenuStrip is dynamically created when the form is loaded. The MenuStrip contained on this UserControl is correctly merged with the Menu of the MDI container. In response to a button click on the child form, an instance of another UserControl is created, containing a different Menu and the previously UserControl instance is discarded. The expected action is that the menu of the second UserControl will replace the menu of the first UserControl on the MDI container menu, but this is not happening and the main menu keeps the menu items of the first UserControl.

How can I force the merging of the menu contained on the second user control with the Main Menu.

Thanks in advance.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend