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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select all text in a grid (selectonentry?)

Status
Not open for further replies.

TomLeMes

MIS
Mar 19, 2004
96
0
0
GB
I have a grid which allows users to enter figures into one of the columns (I've heard that user entry grids are a nightmare, but I have no choice in the matter!). I would like to have it so that when my user enters that column (whether clicking or tabbing) all the text within that cell is selected.

I've tried using:
Code:
format = 'k'
Code:
selectonentry = .t.
I've also tried using this in the gotfocus event:
Code:
.SelStart = 0
.SelLength = LEN(This.Text)
but none of these seem to work.

Marcia's post here (thread1254-820709) gives exactly the behaviour I'm looking for in a standalone textbox (on the gotfocus event):
Code:
WITH This
  IF .SelectOnEntry
    TextBox::GotFocus()
    .SelStart = 0
    .SelLength = LEN( This.Text )
    NODEFAULT
  ENDIF
ENDWITH
but when I'm working with a textbox within a column (within a grid) it doesn't work. I notice that format and selectonentry apply to both textboxes and columns - am I right in thinking that the column would take precedence in this situation? Any ideas how I can get the Marcia's excel type behaviour in a grid?
 
OK! Seems like a good nights sleep has partially helped! On the grid cell's Click event:
Code:
this.setfocus
and on the cell's gotfocus event:
Code:
KEYBOARD '{CTRL+A}'
THIS.SetFocus()
This at least gives me the select all on enter behaviour which was the main part of what I was after. It's not perfect - it would be nice if the first click would select all the text (as it does now), but a second click would put the cursor in so you could then edit the existing value rather than replacing it. Any ideas?
 
Hmmm, perhaps I was still half asleep! Take out the code on the click event and it's all good.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top