473,396 Members | 2,151 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Capture clicked word in RTF control in 2010

228 100+
Hi,

I have a rich text box control in my form. Much like Concise Oxford Dictionary, when user clicks on any word, I need to capture it and process it. The click event don't help and I can't seem to figure it out.

Any tips?
Aug 13 '11 #1

✓ answered by R MacDonald

Hello, samvb,

The MouseClick event provides a MouseEventArgs argument (e) which in turn provides properties e.x and e.y that indicate the location where the click event took place. You could pass this information to the RichTextBox's GetCharIndexFromPosition method to get the index of the character where the user clicked. Using this as a starting point, then search both backwards and forwards through the Text to find the boundaries of the word clicked by the user.

Cheers,
Randy

3 1817
kadghar
1,295 Expert 1GB
Remember that when your textbox is not selected, when you clic on it you'll only select the control. Once it's selected, when you clic on some part of the text, you'll change the selection.

In this case, check where the selection is and (perhaps using INSTR and INSTRREV for blank spaces) select the entire word, then look for it. The clic method should work fine then.
Aug 16 '11 #2
samvb
228 100+
Thanks for your help. Actually, selection and clicking is not part of the option.I want something like Oxford Concise Dictionary's feature. If I fail, i will go your way.
Aug 16 '11 #3
Hello, samvb,

The MouseClick event provides a MouseEventArgs argument (e) which in turn provides properties e.x and e.y that indicate the location where the click event took place. You could pass this information to the RichTextBox's GetCharIndexFromPosition method to get the index of the character where the user clicked. Using this as a starting point, then search both backwards and forwards through the Text to find the boundaries of the word clicked by the user.

Cheers,
Randy
Aug 21 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: gokul | last post by:
Hi, Iam a newbie to dotnet and I experience problems in using the Browser control in VB .net. Though Iam able to use it with its basic features, I need to customise it. ...
0
by: Klein | last post by:
I have an application which can load ms word documents and save them. The application has a main form with a file menu, an edit menu and a tool bar. I have a DocumentControl(usercontrol) defined...
6
by: Ron Vecchi | last post by:
I need to allow my control when it is visible to capture the mouse and not let any other control react to mouse events until control is hidden. Similar to ContextMenu Any Suggestions --...
1
by: Dean Slindee | last post by:
Is there a control that can be placed on a form to display a *.doc file and preserve the text and images intact? Read only would be OK, no updating of the document needed. Thanks, Dean...
0
by: Jon Paal | last post by:
To produce 1 dynamic chart, I add a control to my aspx page positioned in a placeholder. I need to have more than one chart and need to capture the chart control output so it can be complemented...
7
by: Mateusz Rajca | last post by:
Hello, I am writing a text editor in C#. Is there any good and free text control similar to Word? Matt
1
by: MCM | last post by:
How do I capture an Image (Bitmap) of one of my controls (in a Windows Form App) and place it on the clipboard in C#? Thanks, - M
13
by: =?Utf-8?B?RG9uYWxkIEZpc2hlcg==?= | last post by:
Hello. I'm trying to capture a controls value: a dropdown box with two selections (either "Red" or "Blue") keeps returning the value "Red" even if "Blue" is selected?
0
by: Andy B | last post by:
I have a wizard I am using to step a user through creating some documents that will eventually be saved as xml at the end of the wizard. What controls would I need to use to do the following? I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
jinu1996
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.