Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. RichTextBox RightClick [modified]

RichTextBox RightClick [modified]

Scheduled Pinned Locked Moved C#
questionworkspace
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    V 0
    wrote on last edited by
    #1

    [EDIT]We have a workaround now, because the workflow would result in other errors :-)[/EDIT] I should 'simulate' a left-click or set the cursor to the position of the mouse, when right clicking (popup contextmenu) is occuring. I tried mainly this:

    mea = new MouseEventArgs(MouseButtons.Left, e.Clicks, e.X, e.Y, e.Delta);
    OnMouseClick(mea);

    but that doesn't work. I also tried to move my cursor position:

    Cursor.Position = new Point(e.X, e.Y);

    but nothing works. My guess is that the context menu is ahead of me although I should think that OnMouseDown would be before the contextmenu request? How can I do this? Many thanks !

    V.
    Stop smoking so you can: Enjoy longer the money you save. Moviereview Archive

    modified on Thursday, October 23, 2008 10:03 AM

    J 1 Reply Last reply
    0
    • V V 0

      [EDIT]We have a workaround now, because the workflow would result in other errors :-)[/EDIT] I should 'simulate' a left-click or set the cursor to the position of the mouse, when right clicking (popup contextmenu) is occuring. I tried mainly this:

      mea = new MouseEventArgs(MouseButtons.Left, e.Clicks, e.X, e.Y, e.Delta);
      OnMouseClick(mea);

      but that doesn't work. I also tried to move my cursor position:

      Cursor.Position = new Point(e.X, e.Y);

      but nothing works. My guess is that the context menu is ahead of me although I should think that OnMouseDown would be before the contextmenu request? How can I do this? Many thanks !

      V.
      Stop smoking so you can: Enjoy longer the money you save. Moviereview Archive

      modified on Thursday, October 23, 2008 10:03 AM

      J Offline
      J Offline
      JoeSharp
      wrote on last edited by
      #2

      hi use int index = RichTextBox.GetCharIndexFromPoint(Point pt); to get the position of the char under the mouse. use RichTextBox.SelectionStart = index; RichTextBox.SelectionLength = 0; // maybe this line is not necessary to move the cursor inside the textbox. regards

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups