toolstripitem

Access and disable ToolStripItems (ToolStripButtons, ToolStripMenuItems) using their names

廉价感情. 提交于 2020-12-12 06:50:27
问题 I would like to disable UI elements (Controls, Components etc.) which names are stored in a database. My code works for Controls, but I would like to access (to disable them) ToolStripItems such as ToolStripButtons, ToolStripMenuItems etc.. This is my current code: Dim df_command As New SqlCommand("select * from treftab where ref_data = 'INTERVENTION' and ref_code = '0'", sfacon) Dim df_reader As SqlDataReader = df_command.ExecuteReader If df_reader.HasRows Then While df_reader.Read Dim

Access and disable ToolStripItems (ToolStripButtons, ToolStripMenuItems) using their names

情到浓时终转凉″ 提交于 2020-12-12 06:49:06
问题 I would like to disable UI elements (Controls, Components etc.) which names are stored in a database. My code works for Controls, but I would like to access (to disable them) ToolStripItems such as ToolStripButtons, ToolStripMenuItems etc.. This is my current code: Dim df_command As New SqlCommand("select * from treftab where ref_data = 'INTERVENTION' and ref_code = '0'", sfacon) Dim df_reader As SqlDataReader = df_command.ExecuteReader If df_reader.HasRows Then While df_reader.Read Dim

How do I programmatically wire up ToolStripButton events in C#?

こ雲淡風輕ζ 提交于 2019-12-17 21:32:19
问题 I'm programmatically adding ToolStripButton items to a context menu. That part is easy. this.tsmiDelete.DropDownItems.Add("The text on the item."); However, I also need to wire up the events so that when the user clicks the item something actually happens! How do I do this? The method that handles the click also needs to receive some sort of id or object that relates to the particular ToolStripButton that the user clicked. 回答1: Couldn't you just subscribe to the Click event? Something like

Detect right click on toolstrip button

萝らか妹 提交于 2019-12-13 21:05:59
问题 I have a toolstrip with a context menu and a toolstrip button in it with a click event. Initially I tried to assign the context menu to the button itself, but couldn't find a context menu in its property. So I assigned the context menu to the toolstrip. Now whenever I right click the button for the context menu to appear, the button click event is triggered. I want to check which mouse button is clicked, so I tired to cast event args to mouseeventargs: if (((MouseEventArgs)e).Button !=

Deselect ToolStripItem on ContextMenuStrip

六眼飞鱼酱① 提交于 2019-12-08 07:04:38
问题 Simple question: I can .Select a ToolStripItem (like, if i want a preselected option when opening a context menu strip) but i cannot seem to find a way to set .Selected to false or somehow deselect it! Is it possible? 回答1: There is private method ClearAllSelections in ToolStrip class, which removes selections from items. You can invoke it via reflection: MethodInfo method = typeof(ToolStrip).GetMethod("ClearAllSelections", BindingFlags.NonPublic | BindingFlags.Instance); method.Invoke

Adding Items to ToolStrip at RunTime

不想你离开。 提交于 2019-12-07 04:46:39
问题 Hello I have a ToolStripMenu with a "Favorites" menu that I want to add sub items to during my WinForms app at run time. I have a datagridview that I right click on to show a context menu that has an "Add to Favorites" option. When that event is fired, I'd like to add an item using maybe some text from the selected row from the datagriview (this I know how to do already) to this Favorites menu. The tricky part to is I need to create code for my newlyCreatedToolStripMenuItem_Click event. I

Adding Items to ToolStrip at RunTime

吃可爱长大的小学妹 提交于 2019-12-05 08:20:30
Hello I have a ToolStripMenu with a "Favorites" menu that I want to add sub items to during my WinForms app at run time. I have a datagridview that I right click on to show a context menu that has an "Add to Favorites" option. When that event is fired, I'd like to add an item using maybe some text from the selected row from the datagriview (this I know how to do already) to this Favorites menu. The tricky part to is I need to create code for my newlyCreatedToolStripMenuItem_Click event. I will determine how to save my favorites list later. So we're going for: Right click datagridview row for

Mouse wheel scrolling Toolstrip menu items

瘦欲@ 提交于 2019-12-04 01:46:46
问题 I have some menus that contain many menuitems. Mouse wheel doesn't scroll them. I have to use the keyboard arrows or click the arrows at top and bottom. Is it possible to use the mouse wheel to scroll toolstrip menu items? Thanks 回答1: A working solution: Register for MouseWheel event of your form and DropDownClosed event of your root MenuStripItem (here, rootItem) in the Load event of the form this.MouseWheel += Form3_MouseWheel; rootItem.DropDownOpened += rootItem_DropDownOpened; rootItem