Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: Mon, 24 Apr 2006 06:51:24 -0700,    group: microsoft.public.dotnet.framework.windowsforms.designtime        back       


How to track current index in the textbox string   
Hi All

I have developed a custom user control for onscreen Keyboard functionality.
When user clicks any button then it should act accordingly and add the
appropriate character into the string or do the appropriate action(Delete,
Backspace etc).
Now if user sets cursor in the middle of the string in textbox and then
clicks
keyboards button for example 'a' then how to find the index where cursor
exist in the textbox and add 'a' to that perticullar location. At the moment
I am adding every character on the last index of the string but this is not
appropriate.
Any hint or any solution which can help me get going will be highly
appreciated.


Thanks In Advance


Regards
Fiaz Ali Saleemi
date: Mon, 24 Apr 2006 06:51:24 -0700   author:   Fiaz Ali Saleemi

Re: How to track current index in the textbox string   
If you know that SelectionLength is 0 you can simply use SelectionStart

However, if SelectionLength is not 0, the caret can be at either end of the 
selection, meaning SelectionStart is of no use to you. In that case you'll 
need to use P/Invoke and call GetCaretPos and then issue a EM_CHARFROMPOS 
message to the textbox


Another approach is to put your character on the clipboard and the call the 
Paste method. That would put it at the correct location automatically. You 
might want to save the old clipboard content first so you can restore it 
afterwards.

  /claes


"Fiaz Ali Saleemi"  wrote in message 
news:esVXvY6ZGHA.3496@TK2MSFTNGP05.phx.gbl...
> Hi All
>
> I have developed a custom user control for onscreen Keyboard 
> functionality.
> When user clicks any button then it should act accordingly and add the
> appropriate character into the string or do the appropriate action(Delete,
> Backspace etc).
> Now if user sets cursor in the middle of the string in textbox and then
> clicks
> keyboards button for example 'a' then how to find the index where cursor
> exist in the textbox and add 'a' to that perticullar location. At the 
> moment
> I am adding every character on the last index of the string but this is 
> not
> appropriate.
> Any hint or any solution which can help me get going will be highly
> appreciated.
>
>
> Thanks In Advance
>
>
> Regards
> Fiaz Ali Saleemi
>
>
date: Mon, 24 Apr 2006 10:25:19 -0400   author:   Claes Bergefall am

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us