By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,027 Members | 1,297 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,027 IT Pros & Developers. It's quick & easy.

Context menu problem on RichTextBox

P: n/a
JJ
I'm trying to create the cut/paste/select all context menu on number of
richtextboxes.

On the contextmenu.popup handler, I want to find out what control is
currently displaying the context menu. I thought I could use:

Private Sub KL_ClipboardContMenu_Popup(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles KL_ClipboardContMenu.Popup
'To find out which control is displaying the context menu:
Try
Dim thisControl As Control = KL_ClipboardContMenu.SourceControl
Debug.WriteLine(thisControl.ToString)
Catch ex As Exception
Debug.WriteLine("oops!!!" & ex.Message)
End Try
end sub
- an exception if thrown if the control is a rich text box, and not a
textbox. How am I supposed to do this with a rich text box?

Thanks
Feb 20 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
JJ
Ah - I found this. Is there another way of getting the control that is
displaying the context menu?? :

"From your description, you would like to get the
ContextMenu.SourceControl when right click on the Richtextbox.
However, the SourceControl property isn't set by the RTB.

I made a test with a Picturebox and a RTB. When bringing up a
Contextmenu for Picturebox, it has correctly SourceControl set.
However, when bringing up a Contextmenu for RTB, it has nothing if
the first click on the RTB or it shows
System.Windows.Forms.PictureBox if you r_click firstly on the
picturebox then r_click on the RTB.

I checked our bug database. It is a known bug for the RTB. That is
because RichTextBox does not set SourceControl property when the
ContextMenu was brought up.

It is possible that this bug will be fixed in the next version of Visual
Studio, but I can't guarantee a resolution of this issue at this time.

thanks,
Rhett Gong [MSFT]
Microsoft Online Partner Support

This posting is provided "AS IS" with no warranties, and confers no
rights."

"JJ" <ab*@xyz.com> wrote in message
news:uh**************@TK2MSFTNGP12.phx.gbl...
I'm trying to create the cut/paste/select all context menu on number of
richtextboxes.

On the contextmenu.popup handler, I want to find out what control is
currently displaying the context menu. I thought I could use:

Private Sub KL_ClipboardContMenu_Popup(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles KL_ClipboardContMenu.Popup
'To find out which control is displaying the context menu:
Try
Dim thisControl As Control = KL_ClipboardContMenu.SourceControl
Debug.WriteLine(thisControl.ToString)
Catch ex As Exception
Debug.WriteLine("oops!!!" & ex.Message)
End Try
end sub
- an exception if thrown if the control is a rich text box, and not a
textbox. How am I supposed to do this with a rich text box?

Thanks

Feb 20 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.