Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7036711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:27:24+00:00 2026-05-28T01:27:24+00:00

I have the following event handler: private void rtb_MouseDown(object sender, MouseEventArgs e) { if

  • 0

I have the following event handler:

private void rtb_MouseDown(object sender, MouseEventArgs e)
{
    if (e.RightButton == MouseButtonState.Pressed)
    {
        // Get the nearest TextPointer to the mouse position. 
        TextPointer location = rtb.GetPositionFromPoint(Mouse.GetPosition(rtb), true);

        // Get the nearest word using this TextPointer. 
        TextRange word = GetWordRange(location);

        // Display the word. 
        tb.Text = word.Text;

        e.Handled = true;
    }
}

This is wired to the PreviewMouseDown event of a RichTextBox. This event fires and the above method is invoked, and the word under the cursor is displayed in a separate TextBox (called tb).

The problem is that, afterwards the default context menu (containing cut/copy/paste options) for the mouse right button click event is also displayed. Setting the Handled property to true does not seem to help. How can I have this context menu disabled?

EDIT: Xaml code:

<Window x:Class="rtbTest1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <RichTextBox Height="175" HorizontalAlignment="Left" Margin="10,127,0,0" Name="rtb" VerticalAlignment="Top" Width="483" PreviewMouseDown="rtb_MouseDown" />
        <TextBox Height="59" HorizontalAlignment="Left" Margin="286,24,0,0" Name="tb" VerticalAlignment="Top" Width="186" />
        <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="63,56,0,0" Name="btn1" VerticalAlignment="Top" Width="75" Click="btn1_Click" />
    </Grid>
</Window>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:27:25+00:00Added an answer on May 28, 2026 at 1:27 am

    null it:

    <RichTextBox ContextMenu="{x:Null}"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My event handler looks like this: private void List_KeyPress(object sender, KeyPressEventArgs e) I saw
I have a button click event handler with the following pseudo code: private void
I have the following: <select id=price_select></select> I have an event handler that invokes the
On the MSDN, I have found following: public event EventHandler<MyEventArgs> SampleEvent; public void DemoEvent(string
I have the following bit of code: protected function onEnterFrame(e:Event):void { var diff:Number; //
Hey - I have the following method on my UITableView controller public void RemoveEventFromList(Event
I a WPF application I have the following event-handler of a button-click in a
I have following event class. I have a question related to the Property method
I have the following event listener in SecurityConfig security { active = true useSecurityEventListener
I have the following code bound to the click event of a button: function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.