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

Edit box blues 3

Status
Not open for further replies.

torturedmind

Programmer
Jan 31, 2002
1,052
PH
Hello all,

Been a while since i was here.

Anyways, my question is: Is there a way I can allow adding of texts in an edit box but not edit or delete existing texts? The edit box is some sort of a shared remarks from several users who may or may not want to put remarks on specific records of events. Any input is very much appreciated.

Regards,


kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 
Hi,

Well you have to enter the text you want to append somewhere.

What about?

ThisForm.edtBox.Value = Alltrim(ThisForm.edtBox.Value) + " - " + NewText

hth

MK
 
It's not very clear what do you mean by
torturedmind said:
I can allow adding of texts in an edit box but not edit ... existing texts

You can add some properties to the editbox to store the basic text and / or the remarks, so you can easily switch between the text with / without remarks.

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
I would do it this way:

Provide two edit boxes: one for the accumulated text that all users have entered, and one for "new remark", for the present user. Make the first one read-only, and the second one read-write.

After the user has added their remark to the second box, have them click a button to move it to the first box. To do that, simply concatenate the contents of the second box with that of the first:

[tt]THISFORM.Edit1.Value = ALLTRIM(THISFORM.Edit1.Value) + CHR(13) + CHR(10) + ALLTRIM(THISFORM.Edit2.Value)[/tt]

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks to all you inputs. They all good suggestions. But I think I should've mentioned earlier, the edit box is contained in a grid and the grid is the only control on a maximized form. The column where the edit box resides is the only "writeable" column while the rest are read-only. What I was trying to achieve is to just use that edit box as the only I/O facility for the users. I could make the users press some key combination so that another form will appear for their remarks entry. I think that's basicall what you all are trying to suggest. I thought I could try doing it another way. But then again, maybe I should just go to the simplest of solutions?

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 
You can also use DynamicControl to switch between two or more editboxes.
A particular event (can be a keyboard combination) will change the state of the current row from "view/readonly" to "comment/readwrite".

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
You have to be a bit careful with grids and long text elements - they sometimes cause VFP to crash.

I would provide a pop-up form that you can activate by clicking into the edit box in the grid, and only show the
bulk of the most recent comment in the grid, doing what Mike lewis suggested on the pop-up

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
Then your form will somewhat resemble a Forum with a list of posts? If each record has a user ID associated you could enable editing only to that user and of course the current user may add a record to make his own comment in the list. There is no such Thing as dynamicreadonly, but you can use the WHEN Event and return .f. if the logged in user is not the author of the text, and return .T. if that matches.

If you don't yet have multiple records for comments on the same Thing, then you may add that.

Bye, Olaf.

 
This sounds more like a user interface issue. Like Griff, I don't like the idea of an edit box in a grid. Either the grid rows won't be tall enough to show anything except a small amount of text; or the rows will be tall, but then you won't see more than a small number of rows at a time.

But, even if you do use a grid, I would stick with my idea of a separate text box for the new remark. That could be on the same form as the grid, or on a separate form that pops up - perhaps when the user double-clicks in the "main" textbox.

My point is that you should decide what user interface you want for this feature, then worry about how best to implement it - not the other way round.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I'd do something with SelStart to prevent it from ever being less than what it was when you enter the editbox. Something like add a custom property, nOrigStart, to the editbox; then, in GotFocus, set This.nOrigStart to This.SelStart; then, in InteractiveChange(?), make sure that SelStart is >= This.nOrigStart, and move it, if necessary.

I'm not sure which event you need for that last part. You'll have to experiment. You might find that you also need to store the original value and restore it if the user has dipped into that part of the text.

Tamar

 
CTRL+A, CTRL+X
DblClick, Del

I'd never try to make a single control partly readonly.

Bye, Olaf.
 
Thanks for all the great inputs. I've already experimented with what Tamar's suggesting before I posted here but unfortunately, something is making the edit box read-only on the first GotFocus even though I don't have any code anywhere telling it to become so. I think I'll stick with the simplest approach and what Mike's suggesting - pop-up for the new text entry while read-only on the main form.

Thanks again. Some stars for you. :)

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top