I have one general context menu and for example 4 buttons and 4 textboxes - when I click on any of these buttons the context menu is opened and when I click on some items I would like to send this item to textbox, which was between button - I need to send some identificator to context menu to know which button open it and then to know where to send selected item.
How can I do that?
I am using c#
Thanks
this.ActiveControl will give you the button that has the focus. You can put the identifier in the Tag property of each button. This way, this.ActiveControl.Tag will give you the information you need.
Related
I want to implement the following menu in WPF. Note that the "+" sign changes to a "-" when the Apple button is clicked. And in the opened submenu A.1 to A.5, the mouse over item is highlighted.
How am I going to do this?
There are four options:
The Apple menu is open:
I think control you are looking for is Accordian Control. You can find a good example of accordian here
How can I add an item to a contextmenustrip, as well as code the button_click action for it?
I'm making a web browser application, and I have a drop down menu of 'favorite' websites. When someone clicks a button, it adds the title of the website into the dropdown menu, but I also need it navigable to the website URL that was inputted. I have no idea how to add button click actions when I add a new item to a contextmenustrip.
Is this a WinForms application?
If so, in the Visual Studio designer, after you drag a contextMenuStrip from the boolbox, it allows you to type new entries at the contextMenuStrip (click where it says 'Type Here' to add a new item). If you are going back to an existing contextMenuStrip, you will have to make it appear by clicking on the contextMenuStrip item at the bottom of the designer.
Once you have the item, you can just double-click on it to whatever code you want to execute on the click event. (This is the default event; for other events you will have to double-click the appropriate event from the Properties pane.
I have three tabs in a Windows Forms tab control. Currently in Tab1 I have a button that saves the information in a textbox and automatically changes the tabcontrol.SelectedIndex to Tab2. Tab2 then uses the information saved from tab1's textbox.
I want a messagebox to popup whenever the user changes the textbox in tab1, but then manually clicks tab2 or tab3 without hitting the button to save the information.
So in summary, I have it so clicking a button on tab1 automatically sends it to tab2. I want a messagebox to pop up if the button on tab1 is not pressed when the information was changed and the user manually changed the tab.
I think a wizard-like design for your application is more appropriate. Tabs are not supposed to work like that from a user's perspective.
But a workaround for your current situation is:
declare a variable, for example dirty
set this variable whenever any control in tab1 has been edited
clear the variable if the button in tab1 is clicked
check this if tab2 or tab3 is selected
You can use the Deselecting event on the TabControl to be informed when the selected tab is changing. If the tab that is being deselected is the tab with the button on it and the information is not saved, you can display the message box.
Also, depending on what your program does, it may make more sense to go ahead and save the information when the tab changes without even bothering the user.
I am contemplating having a menu in my WPF application that works in a similar way to the Windows 7 start menu.
In my mind, this means that I should make a user control that consitues a button. Clicking on the button will display a list box, and inside the list box it will be possible to search the items that are registered in the list box.
Would that be an advisable way of doing it or is it better to do something different such as changing the template of a menu control?
Thanks for any help, it is very much appreciated.
It seems you have the design already made up. Do exactly that! :) Create a button that when pressed, displays a panel that contains a list box and a text box. Tie an event to key presses in the text box that changes what the object bound to the list contains.
After that, it's just a SMOP!
Is there some way to use the Menu.AttachToWidget(...) function of a gtk menu item to attach the menu to say a Gtk.Textview and have it handle showing the menu when needed. Or is creating an event handler for ButtonPressEvent and showing the menu there the only way to do it?
Or is there a third possibility that I'm missing?
Thanks in Advance.
There is a third possibility that you are missing.
TextView.PopulatePopup is an event that TextView fires when the user right clicks within the TextView. You can handle this event and insert menu items into the existing TextView context menu, which has items for cut/copy/paste and input method. This is the preferred way of adding additional context menu items to TextView.
Links to docs:
TextView
PopulatePopupHandler