Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rich textbox - Tab insertion

Status
Not open for further replies.

cmergal

MIS
Oct 16, 2002
18
US
Hello All:

I have a form that contains several controls including an ole rich textbox. The problem is that within the box I am not able to use the TAB key to insert the TAB characters. I read on a MS tech article that you have to set all the controls' tabstop property to .F. so I did. But this did not do the trick, the cursor stays in position without moving. Do I have to do something else?

TIA,

Carlos
 
Carlos,

Have you set up any tab stops within the control? You need to do something like this:

WITH MyForm.RichTextBox
.SelTabCount = 2 && the number of tab stops
.SelTabs(1) = 8 && first tab stop
.SelTab(2) = 16 && second tab stop
ENDWITH

You still have to do the business with setting the tabstop property of all the other controls to .F.

A simpler approach is to get the user to hit Ctrl-Tab instead of Tab. But I doubt if the users will be happy with that.

Mike


Mike Lewis
Edinburgh, Scotland
 
Mike,

Have you been able to test this. I think you are right and that's the way to go, but we are still missing something because I get the same results. This is what I have in the click event (just for testing purposes) of the rtf control:

thisform.SetAll('Tabstop', .f. )
WITH Thisform.msgtext
.SelTabCount = 2 && the number of tab stops
.SelTabs(0) = 8 && first tab stop
.SelTabs(1) = 16 && second tab stop
ENDWITH

BTW, the CTRL+TAB works OK but you are right I would prefer that the user would not have to learn this and use the TAB key alone.

Again thanks,

Carlos

 
Carlos,

No, I haven't tested it. I'll try to find the time to do so later.

So, are you saying that it still doesn't work? If so, I really don't know what to do next. Anyone else got any ideas?

Mike


Mike Lewis
Edinburgh, Scotland
 
Hi Carlos,

One workaround is to simulate the CTRL+TAB in KeyUp event, however it's not smooth. Using KEYBOARD command is not working but WSH.SendKeys or keybd_event API works

Try this if you want:
** Form Init event
ThisForm.oWSH = CreateObject('WScript.Shell')

** RichText KeyUp event:
ThisForm.oWSH.SendKeys('^{TAB}')

Hope it helps

-- AirCon --
 
Ahh..typo :)

** RichText KeyUp event:
If (shift == 0) and (KeyCode == 9)
ThisForm.oWSH.SendKeys('^{TAB}')
endif

Regards

-- AirCon --
 
Aircon:

Thanks a lot it did work! I was considering something like this but wasn't sure how to get to it. It's a little frustrating that you have to create an additional object to accomplish something that the control is supposed to do. But the user wouldn't know the difference!

Thanks all for the help!

Carlos.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top