Suppress default right click menu in datagridview vb.net - vb.net

I have my own right click menu for a datagridview, however when a user in in edit mode and right clicks on the cell that he is editing both the default and my own menu come up and they overlap. I have moved mine to a side but its unsightly. Is there a way that I can supress the default right click menu and only have mine show ? Im using VB.net. Thanks
In a short eg here is the code that creates my menu
Dim menu As ContextMenuStrip = New ContextMenuStrip
menu.Items.Add(ShowMenuItem1, Nothing, AddressOf MenuG5_ShowMenuItem1)
menu.Items.Add(ShowMenuItem1, Nothing, AddressOf MenuG5_ShowMenuItem2)
menu.show

I guess you can just set contextmenu strip visibility property to false....

Related

Set backgroundcolor of every form in vb.net

How can I set the BackColor of every form that exists in my vb.net (fw 4.7.2) project?
And yes, I could do
Form1.BackColor = ...
Form2.BackColor = ...
......
but that would be too messy then.
Open one of your forms in the designer, any form, doesn't matter
Click the form background
In the property grid, at the top, go to (Application Settings) then click the dots button in (Property Binding), find BackColor in the list of proeprties, click the dropdown next to it and click New at the bottom
Call your setting ThemeColor, pick the color you want for the light theme, such as White
OK everything
Open the designer for another form, go Application Settings/Property Binding again. This time don't click New, just bind BackColor to the existing ThemeColor setting
Repeat for all forms in your app
Add a button to the "Settings" form (or wherever you want to offer a toggle for the theme), and in its click handler write:
My.Settings.ThemeColor = Color.White
Add another button to the form, make its click handler set Color.Black
Run the application. Open one or more forms, including the settings form. Click one of the buttons to change the setting. All forms change color
You could:
For Each f as Form in Application.OpenForms
f.BackColor = Color.Red
Next f
at any point after you've opened a boatload of forms
.. or you'd just set the back color in the designer if you were designing a form and you wanted every form instance of that form that you created be red as soon as it was shown
I would have said you could create a class:
Public Class ColoredForm
Inherits Form
Public Sub New()
Me.BackColor = Color.Red
End Sub
End Class
And then in every form you add, open the designer and change the code so that it Inherits this form instead; but it's messing with the designer files (not everyone wants to do it, and changes could be lost if they were regenerated) and isn't actually any different to just.. setting the back color in the designer property grid. If you have some more involved behavior you want all your forms to adopt then consider an inheritance, but if it's as trivial as setting the BackColor, just do it in each form as a design time thing (If you have a lot of forms, can use find/replace for it)

Add user control to panel on button click

I'm new to VB.NET and struggling with below.
In my button click event I'm trying to add a user control every time a button is clicked. I only ever see one control, I presume I'm just overwriting each time. How do I get it to display each version in the list?
Dim ucMyCtrl As New MyControl
pnlAddMyControl.Controls.Add(ucMyCtrl )

VB.Net Menu strip hover

I have these menu in my form but when I hover on the disabled item and continue to the next enabled item, sub menus stop from showing...Is this the new default behavior of vb.net? Because in vb6 sub menus will still continue to show. Please help.

Assign Event by Event Handler

In my application i am using Krypton Component Factory.
My application i have Ribbon Menu and Some krypton buttons. In krypton buttons i want to assign click event of Ribbon Menu Group Button at run time. The events of Ribbon Menu Group Button Changed Based some condition so i tried like this
Dim eventsField = GetType(Component).GetField("events", BindingFlags.NonPublic Or
BindingFlags.Instance)
Dim eventHandlerList = eventsField.GetValue(KryptonRibbonGroupButton1)
eventsField.SetValue(KryptonButton1, eventHandlerList)
Its not work. The Get Field always return nothing.
Problem: I want add handler of Krypton Button Click event by old ribbon menu button throw coding using the controls name only. Its Possible or not? Its possible how to do it?
am using Vb.Net
Perhaps you're looking for AddHandler?

Tabpage is empty after adding user control to vb.net tabpage

I am trying to display an usercontrol(has several panels one on top of the other panel) on tabpage. I am using below code to achieve this.
Dim ctrl As TechniciansControl = New TechniciansControl
TabControl1.TabPages(2).Controls.Add(ctrl)
The problem is that the control doesn't show anything. I verified the control is created correctly. The tabpage is empty. It works for other usercontrol which has only one panel.
Appreciate any ideas to fix this issue.
Make sure that the control is visible and, also, make sure that it's location is within the viewable client area of the tab control.