Hi,
I am trying to show the shortcut menu on a richtextbox control by
adding the contextmenu component onto the form. The richtextbox
property is assigned to the contextmenu. I created my shorcuts, copy,
paste, etc. However, on the form I have a datagrid
which is also assigned to the same contextmenu and contextmenupopup
event as follows:
....
If ContextMenu1.SourceControl Is richtextbox1Then
' Add MenuItems to display for the TextBox.
ContextMenu1.MenuItems.Add(menuItem1)
ContextMenu1.MenuItems.Add(menuItem2)
ElseIf ContextMenu1.SourceControl Is datagrid1 Then
' Add the MenuItem
ContextMenu1.MenuItems.Add(menuItem3)
End If
....
when I right-click on the richtext control I get the sourcecontrol =
Nothing, but r-click on grid
i get the control name. I droped the richtext control and added another
one and set the
cmenu property and still nothing. Any idea?
Thanks in advance 7 2185
Need some more code, like the event handler sub declaration and what it
handles.
--
Dennis in Houston
"wandii" wrote:
Hi,
I am trying to show the shortcut menu on a richtextbox control by
adding the contextmenu component onto the form. The richtextbox
property is assigned to the contextmenu. I created my shorcuts, copy,
paste, etc. However, on the form I have a datagrid
which is also assigned to the same contextmenu and contextmenupopup
event as follows:
....
If ContextMenu1.SourceControl Is richtextbox1Then
' Add MenuItems to display for the TextBox.
ContextMenu1.MenuItems.Add(menuItem1)
ContextMenu1.MenuItems.Add(menuItem2)
ElseIf ContextMenu1.SourceControl Is datagrid1 Then
' Add the MenuItem
ContextMenu1.MenuItems.Add(menuItem3)
End If
....
when I right-click on the richtext control I get the sourcecontrol =
Nothing, but r-click on grid
i get the control name. I droped the richtext control and added another
one and set the
cmenu property and still nothing. Any idea?
Thanks in advance
Dennis wrote:
Need some more code, like the event handler sub declaration and what it
handles.
--
Dennis in Houston
"wandii" wrote:
Hi,
I am trying to show the shortcut menu on a richtextbox control by
adding the contextmenu component onto the form. The richtextbox
property is assigned to the contextmenu. I created my shorcuts, copy,
paste, etc. However, on the form I have a datagrid
which is also assigned to the same contextmenu and contextmenupopup
event as follows:
....
If ContextMenu1.SourceControl Is richtextbox1Then
' Add MenuItems to display for the TextBox.
ContextMenu1.MenuItems.Add(menuItem1)
ContextMenu1.MenuItems.Add(menuItem2)
ElseIf ContextMenu1.SourceControl Is datagrid1 Then
' Add the MenuItem
ContextMenu1.MenuItems.Add(menuItem3)
End If
....
when I right-click on the richtext control I get the sourcecontrol =
Nothing, but r-click on grid
i get the control name. I droped the richtext control and added another
one and set the
cmenu property and still nothing. Any idea?
Thanks in advance
Thanks for your time Dennis. Here you go... I have the property of
datagrid and richtext
are assigned to contextmenu. Works fine for the datagrid and I get
nothing for the rtext. Thanks
Public Sub ContextMenu1_Popup(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles ContextMenu1.Popup
' Define the MenuItem objects to display for the TextBox.
Dim menuItem1 As New MenuItem("&Copy")
Dim menuItem2 As New MenuItem("&Find and Replace")
' Define the MenuItem object to display for the PictureBox.
Dim menuItem3 As New MenuItem("C&hange Picture")
' Clear all previously added MenuItems.
ContextMenu1.MenuItems.Clear()
If ContextMenu1.SourceControl Is richtextbox1Then
' Add MenuItems to display for the TextBox.
ContextMenu1.MenuItems.Add(menuItem1)
ContextMenu1.MenuItems.Add(menuItem2)
ElseIf ContextMenu1.SourceControl Is datagrid1 Then
' Add the MenuItem to display for the PictureBox.
ContextMenu1.MenuItems.Add(menuItem3)
End If
Your code looks fine. Are you able to type information into the richtextbox
to be sure it can get the focus? Also, does the contextmenu1 appear when you
right click on the richtextbox?
--
Dennis in Houston
"wandii" wrote:
>
Dennis wrote:
Need some more code, like the event handler sub declaration and what it
handles.
--
Dennis in Houston
"wandii" wrote:
Hi,
I am trying to show the shortcut menu on a richtextbox control by
adding the contextmenu component onto the form. The richtextbox
property is assigned to the contextmenu. I created my shorcuts, copy,
paste, etc. However, on the form I have a datagrid
which is also assigned to the same contextmenu and contextmenupopup
event as follows:
....
If ContextMenu1.SourceControl Is richtextbox1Then
' Add MenuItems to display for the TextBox.
ContextMenu1.MenuItems.Add(menuItem1)
ContextMenu1.MenuItems.Add(menuItem2)
ElseIf ContextMenu1.SourceControl Is datagrid1 Then
' Add the MenuItem
ContextMenu1.MenuItems.Add(menuItem3)
End If
....
when I right-click on the richtext control I get the sourcecontrol =
Nothing, but r-click on grid
i get the control name. I droped the richtext control and added another
one and set the
cmenu property and still nothing. Any idea?
>
Thanks in advance
>
>
Thanks for your time Dennis. Here you go... I have the property of
datagrid and richtext
are assigned to contextmenu. Works fine for the datagrid and I get
nothing for the rtext. Thanks
Public Sub ContextMenu1_Popup(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles ContextMenu1.Popup
' Define the MenuItem objects to display for the TextBox.
Dim menuItem1 As New MenuItem("&Copy")
Dim menuItem2 As New MenuItem("&Find and Replace")
' Define the MenuItem object to display for the PictureBox.
Dim menuItem3 As New MenuItem("C&hange Picture")
' Clear all previously added MenuItems.
ContextMenu1.MenuItems.Clear()
If ContextMenu1.SourceControl Is richtextbox1Then
' Add MenuItems to display for the TextBox.
ContextMenu1.MenuItems.Add(menuItem1)
ContextMenu1.MenuItems.Add(menuItem2)
ElseIf ContextMenu1.SourceControl Is datagrid1 Then
' Add the MenuItem to display for the PictureBox.
ContextMenu1.MenuItems.Add(menuItem3)
End If
Sorry Dennis I could not get back to you soon. Yes I tried to setfocus
to richtext on form load and can type into richtext, however, no
contextmenu appears when I r-click on
it. I put a breakpoint please see below:
bp If ContextMenu1.SourceControl Is richtextbox1Then
' Add MenuItems to display for the TextBox.
ContextMenu1.MenuItems.Add(menuItem1)
ContextMenu1.MenuItems.Add(menuItem2)
ElseIf ContextMenu1.SourceControl Is datagrid1 Then
' Add the MenuItem
ContextMenu1.MenuItems.Add(menuItem3)
End If
and sourcecontrol is nothing. Plan B: deleted the old richtext control
and added a new one still sourcecontrol is nothing. I tried on a
button, datagrid and sourcecontrol is not
null. Richtext's contextmenu property is to the contextmenu2. This is
very strange?
I am not sure if I need to set another property. Any other
suggestions. Thanks
Dennis wrote:
Your code looks fine. Are you able to type information into the richtextbox
to be sure it can get the focus? Also, does the contextmenu1 appear when you
right click on the richtextbox?
--
Dennis in Houston
"wandii" wrote:
Dennis wrote:
Need some more code, like the event handler sub declaration and what it
handles.
--
Dennis in Houston
>
>
"wandii" wrote:
>
Hi,
I am trying to show the shortcut menu on a richtextbox control by
adding the contextmenu component onto the form. The richtextbox
property is assigned to the contextmenu. I created my shorcuts, copy,
paste, etc. However, on the form I have a datagrid
which is also assigned to the same contextmenu and contextmenupopup
event as follows:
....
If ContextMenu1.SourceControl Is richtextbox1Then
' Add MenuItems to display for the TextBox.
ContextMenu1.MenuItems.Add(menuItem1)
ContextMenu1.MenuItems.Add(menuItem2)
ElseIf ContextMenu1.SourceControl Is datagrid1 Then
' Add the MenuItem
ContextMenu1.MenuItems.Add(menuItem3)
End If
....
when I right-click on the richtext control I get the sourcecontrol =
Nothing, but r-click on grid
i get the control name. I droped the richtext control and added another
one and set the
cmenu property and still nothing. Any idea?
Thanks in advance
Thanks for your time Dennis. Here you go... I have the property of
datagrid and richtext
are assigned to contextmenu. Works fine for the datagrid and I get
nothing for the rtext. Thanks
Public Sub ContextMenu1_Popup(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles ContextMenu1.Popup
' Define the MenuItem objects to display for the TextBox.
Dim menuItem1 As New MenuItem("&Copy")
Dim menuItem2 As New MenuItem("&Find and Replace")
' Define the MenuItem object to display for the PictureBox.
Dim menuItem3 As New MenuItem("C&hange Picture")
' Clear all previously added MenuItems.
ContextMenu1.MenuItems.Clear()
If ContextMenu1.SourceControl Is richtextbox1Then
' Add MenuItems to display for the TextBox.
ContextMenu1.MenuItems.Add(menuItem1)
ContextMenu1.MenuItems.Add(menuItem2)
ElseIf ContextMenu1.SourceControl Is datagrid1 Then
' Add the MenuItem to display for the PictureBox.
ContextMenu1.MenuItems.Add(menuItem3)
End If
Try this code (note the "sender" in the if statments:
Public Sub ContextMenu1_Popup(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles ContextMenu1.Popup
' Define the MenuItem objects to display for the TextBox.
Dim menuItem1 As New MenuItem("&Copy")
Dim menuItem2 As New MenuItem("&Find and Replace")
' Define the MenuItem object to display for the PictureBox.
Dim menuItem3 As New MenuItem("C&hange Picture")
' Clear all previously added MenuItems.
ContextMenu1.MenuItems.Clear()
If Sender Is richtextbox1Then
' Add MenuItems to display for the TextBox.
ContextMenu1.MenuItems.Add(menuItem1)
ContextMenu1.MenuItems.Add(menuItem2)
ElseIf Sender Is datagrid1 Then
' Add the MenuItem to display for the PictureBox.
ContextMenu1.MenuItems.Add(menuItem3)
End If
--
Dennis in Houston
Nope - didn't work. The reason is that the sender listed below is
looking at the contextmenu (1, 2, ...) controls.
Dennis wrote:
Try this code (note the "sender" in the if statments:
Public Sub ContextMenu1_Popup(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles ContextMenu1.Popup
' Define the MenuItem objects to display for the TextBox.
Dim menuItem1 As New MenuItem("&Copy")
Dim menuItem2 As New MenuItem("&Find and Replace")
' Define the MenuItem object to display for the PictureBox.
Dim menuItem3 As New MenuItem("C&hange Picture")
' Clear all previously added MenuItems.
ContextMenu1.MenuItems.Clear()
If Sender Is richtextbox1Then
' Add MenuItems to display for the TextBox.
ContextMenu1.MenuItems.Add(menuItem1)
ContextMenu1.MenuItems.Add(menuItem2)
ElseIf Sender Is datagrid1 Then
' Add the MenuItem to display for the PictureBox.
ContextMenu1.MenuItems.Add(menuItem3)
End If
--
Dennis in Houston
Sorry, I don't know what to try next. Are you sure you spelled the name of
the richtext box correctly? You might want to add a second contextmenu
dedicated to your richtextbox.
--
Dennis in Houston
"wandii" wrote:
Nope - didn't work. The reason is that the sender listed below is
looking at the contextmenu (1, 2, ...) controls.
Dennis wrote:
Try this code (note the "sender" in the if statments:
Public Sub ContextMenu1_Popup(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles ContextMenu1.Popup
' Define the MenuItem objects to display for the TextBox.
Dim menuItem1 As New MenuItem("&Copy")
Dim menuItem2 As New MenuItem("&Find and Replace")
' Define the MenuItem object to display for the PictureBox.
Dim menuItem3 As New MenuItem("C&hange Picture")
' Clear all previously added MenuItems.
ContextMenu1.MenuItems.Clear()
If Sender Is richtextbox1Then
' Add MenuItems to display for the TextBox.
ContextMenu1.MenuItems.Add(menuItem1)
ContextMenu1.MenuItems.Add(menuItem2)
ElseIf Sender Is datagrid1 Then
' Add the MenuItem to display for the PictureBox.
ContextMenu1.MenuItems.Add(menuItem3)
End If
--
Dennis in Houston
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: MD |
last post by:
I have a ContextMenu that is assigned to 3 RichTextBox's (i.e., if you
right-click on any of the 3 RichTextBox's, you get the same ContextMenu).
My ContextMenu has 2 items, each of which have their...
|
by: Derrick |
last post by:
I've been working on an application which has a NotifyIcon (system tray
icon), and a corresponding ContextMenu. I want to be able to update this
menu dynamically. However, when I make changes to...
|
by: Zieben |
last post by:
Hello!
I have such problem!
I have my UserControl. I override property ContextMenu for this
Control as
.....
new ContextMenu ContextMenu{
set {_contextMenu = value;}
|
by: cemino |
last post by:
Hi,
I got a problem with ContextMenu. I'm using a hot-key (like Ctrl-B) to
show contextMenu in my program. Things is like below:
contextMenu.Show(Form1, New...
|
by: tmaster |
last post by:
When I try to dynamically add a second sub menu item to this ContextMenu
item, I get an error 'Specified argument was out of the range of valid
values'.
Private Sub mnuTopics_Show_Select(ByVal...
|
by: TryingLikeHeck |
last post by:
I have a usercontrol on which I've generated a context menu in designer.
The properties of the control lists for ContextMenu (none)
The menu shows up in the designer window and I can edit it
To...
|
by: Graham Charles |
last post by:
I'm writing a control inheriting from ComboBox, and I'd like to add an
entry to the ContextMenu for that combo box. I have no problem if I
create an entirely new ContextMenu from scratch, but I'd...
|
by: Libby Sharf |
last post by:
Hello,
I have several ContextMenus and I want to connect them to the GridControl's
ContextMenu property depending on the row that was right clicked. Is there
an event that is raised just before...
|
by: Steve Richter |
last post by:
I cant get a contextmenu to popup in the context of a datagridview. It
pops up in the ListBox, and in the form itself. But not the
DataGridView. How could that be?
here is my code:
using...
|
by: asharda |
last post by:
Hi,
I am trying to create a context menu in my application. The context
menu takes menu otems from an XML file. In XAML the code is
<Grid.ContextMenu>
<ContextMenu Name="cm" StaysOpen="true"...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |