473,396 Members | 1,678 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.

TextBox SelectionChanged equivalent?

I have a toolbar with Cut, Copy and Paste buttons, which need to be enabled
and disabled as appropriate.

I am using SetClipboardViewer and WM_DRAWCLIPBOARD to monitor Clipboard
changes and update the Paste button.

However, I am having trouble with Cut and Copy, which need to be available
whenever there is a selection in the textbox. Surprisingly, there is no
SelectionChanged event for this control.

What is the correct way of monitoring a textbox for a change in selection? I
don't want to use a timer for this unless I have to!

P.
Nov 15 '05 #1
4 11399
Paul E Collins wrote:

I have a toolbar with Cut, Copy and Paste buttons, which need to be enabled
and disabled as appropriate.

I am using SetClipboardViewer and WM_DRAWCLIPBOARD to monitor Clipboard
changes and update the Paste button.

However, I am having trouble with Cut and Copy, which need to be available
whenever there is a selection in the textbox. Surprisingly, there is no
SelectionChanged event for this control.

What is the correct way of monitoring a textbox for a change in selection? I
don't want to use a timer for this unless I have to!

P.


From a Microsoft post:

<quote>
The TextBox does not have a property such as SelectedText as in the
RichTextBox. You will need to programmatically to go check the selection
length, like what you are doing already.
</quote>

So, you are out of luck -- time to resort to timers.

What is even more frustrating is that there *IS* notification of selection
changes in the native Windows control (EN_SELCHANGE). Very poor framework
implementation, maybe someday .Net will actually be a step forward rather than
5 steps backwards...
Nov 15 '05 #2
"Julie" <ju***@aol.com> wrote:
What is even more frustrating is that there *IS*
notification of selection changes in the native
Windows control (EN_SELCHANGE).


Hmm. Is there a way I could intercept this?

Failing that - MouseUp and KeyPress events will probably cover all possible
text-selecting operations, so perhaps I'll use those rather than a timer.

P.
Nov 15 '05 #3
So, you are out of luck -- time to resort to timers.

What is even more frustrating is that there *IS* notification of selection
changes in the native Windows control (EN_SELCHANGE). Very poor framework
implementation, maybe someday .Net will actually be a step forward rather than 5 steps backwards...

The EN_SELCHANGE event is only for rich edit boxes - the normal edit box
does not fire an EN_SELCHANGE (or any selection change) notification.

Nov 15 '05 #4
Philip Rieck wrote:
So, you are out of luck -- time to resort to timers.

What is even more frustrating is that there *IS* notification of selection
changes in the native Windows control (EN_SELCHANGE). Very poor framework
implementation, maybe someday .Net will actually be a step forward rather

than
5 steps backwards...


The EN_SELCHANGE event is only for rich edit boxes - the normal edit box
does not fire an EN_SELCHANGE (or any selection change) notification.


Crap -- you are right.

Second time today that I've had to retract a statement.
Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: mcr | last post by:
Hi Can anyone tell me how I can use the ShellFolderView.SelectionChanged event from C#? I have an webBrowserClass object. From its document property I get the ShellFolderView interface. From...
0
by: Jimmy | last post by:
I am using Calendar control in my ASP.Net application. When the user clicks a command button, I am making it(calendar control) visible. Once the user selects the date, I am making calendar contol...
1
by: mosquito.dotnet | last post by:
I am getting clearly wrong values from TextBox.SelectionStart property in C# code. For example, if I move caret one character to right by pressing Keys.Right, sometimes declared SelectionStart...
7
by: luanhoxung | last post by:
hi all!! i get small trouble in display a text box. My text box will be show a value string base on my combo box choice. But text box always get the same value when i choose a new value in combo...
13
by: WALDO | last post by:
I have a .Net TextBox (TextBoxBase, really) in which I am appending about 20 lines of text per second. I use the AppendText() method to accomplish this. This is a great substitute for taking the...
5
by: Stuart Shay | last post by:
Hello All I am working on ASP.NET 1.1 Custom Pager that allows a User to Enter a Number in a TextBox and go to the page selected. Since the OnClick Event does not work in ASP.NET 1.1 for a...
2
by: Simon Harvey | last post by:
Hi Guys, Can anyone tell me why the DataGridView.SelectionChanged event fires twice when I databind to it. If I do the following, the first row is selected automatically, but the changed...
24
by: =?Utf-8?B?Tkg=?= | last post by:
I have a basic calendar and a SelectionChanged event (asp.net 2.0). How can I handle it when a user chooses the same date again, in this case the SelectionChanged event is not fired because,...
0
by: Brano | last post by:
Hi all, I have two DataGridViews one has some data in it the other one's data changes according to the selected row in the first dgw. User is allowed to add / change data in the second dgw. 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.