Recent

Author Topic: Editing text in DBEdit box  (Read 1045 times)

erictan

  • Jr. Member
  • **
  • Posts: 52
Editing text in DBEdit box
« on: June 20, 2020, 05:45:27 am »
I have a form with a DBGrid populated with Customer records, the DBGrid is set to ReadOnly.
I have another form with two DBEdit tied to the DBGrid dataset for editing of the customer record.

I have to highlight the whole text in the DBEdit before it will enter into Edit mode.
How can I click the mouse in any of the text position in the DBEdit and it will enter Edit mode for me to insert or delete any text instead of having to enter the whole text again.

I have tried to set many edit options in the DBGrid and DBEdit without success.

eljo

  • Sr. Member
  • ****
  • Posts: 408
Re: Editing text in DBEdit box
« Reply #1 on: June 20, 2020, 12:37:14 pm »
I have a form with a DBGrid populated with Customer records, the DBGrid is set to ReadOnly.
I have another form with two DBEdit tied to the DBGrid dataset for editing of the customer record.

I have to highlight the whole text in the DBEdit before it will enter into Edit mode.
How can I click the mouse in any of the text position in the DBEdit and it will enter Edit mode for me to insert or delete any text instead of having to enter the whole text again.

I have tried to set many edit options in the DBGrid and DBEdit without success.
how do you show the extra form? lets say your form with the dbGRid is call GridForm and  the form with the DBEdits its called EditForm. Now you need a way to show the editform to edit the grid's active record or row. Usually this goes something along the lines of
Code: Pascal  [Select][+][-]
  1. Procedure EditRecord(const aDataSet:TDataset);
  2. var
  3.   Frm:TEditForm;
  4. begin
  5.   Frm := TEditForm.Create(Nil);
  6.   try
  7.     aDataset.Edit;
  8.     if Frm.ShowModal = mrOK then
  9.       aDataset.Post
  10.     Else
  11.       aDataset.Cancel;
  12.   finally
  13.     Frm.Free;
  14.   end;
  15. end;
  16.  

For anything more specific please provide a small sample that demonstrates the current behavior.

jamie

  • Hero Member
  • *****
  • Posts: 3540
Re: Editing text in DBEdit box
« Reply #2 on: June 20, 2020, 12:41:18 pm »
Then there is the EDITMODE property and OnCellClick.

also if you have the option set to allow for complete row selection then it won't allow editing, at least that is how my old Delphi works
The only true wisdom is knowing you know nothing

erictan

  • Jr. Member
  • **
  • Posts: 52
Re: Editing text in DBEdit box
« Reply #3 on: June 20, 2020, 05:31:08 pm »


Thanks eljo and jamie for your reply.

I have a button on the main form calling the 2nd form.
When I scroll down the records on the main form DBGrid, the 2 DBEdit data on the second form follows the data on the main form correctly.

When I click the DBEdit on the 2nd form to edit, I have to highlight the entire text on the DBEdit before it allow editing.
When I click in the middle of a word in the DBEdit to do insertion or deletion of characters, it will not allow me to edit.

I have to highlight the whole text in the DBEdit to activate Edit mode and retype the whole text again even when I want to make a single character changes.

I thought there must be some setting to activate the Edit mode when I click into the DBEdit box without having to highlight the existing text first.

I have tried setting all the available EditMode property without success.



eljo

  • Sr. Member
  • ****
  • Posts: 408
Re: Editing text in DBEdit box
« Reply #4 on: June 20, 2020, 05:39:15 pm »


Thanks eljo and jamie for your reply.

I have a button on the main form calling the 2nd form.
When I scroll down the records on the main form DBGrid, the 2 DBEdit data on the second form follows the data on the main form correctly.

When I click the DBEdit on the 2nd form to edit, I have to highlight the entire text on the DBEdit before it allow editing.
When I click in the middle of a word in the DBEdit to do insertion or deletion of characters, it will not allow me to edit.

I have to highlight the whole text in the DBEdit to activate Edit mode and retype the whole text again even when I want to make a single character changes.

I thought there must be some setting to activate the Edit mode when I click into the DBEdit box without having to highlight the existing text first.

I have tried setting all the available EditMode property without success.
Not in my experience (as limited as ite might be) You need to call Dataset.edit; before you are able to edit the data in any db aware control.  Also you need to call the post after you finish editing the fields otherwise the moment the dbgrid moves to a new row it will automatically call cancel.

As always the above are from memory and it might have changes in the mean time. Post a sample application and your requirements and I'll try to make it work.

erictan

  • Jr. Member
  • **
  • Posts: 52
Re: Editing text in DBEdit box
« Reply #5 on: June 25, 2020, 10:40:39 am »
Hi Eljo, I have attached the sample project with some records for testing, unzip both files into a new folder in D: drive to do the testing.
My issue is as follows:
1. From the main form, click the Details button to display each record details in the Details Form.
    The Details Form is set as Show instead of ShowModal so that the records will follow the Main Form record as I scroll the Grid.
2. When I click anywhere in the Name Edit box, I am not able to do any editing.
    I have to highlight the whole Edit Box before it will allow me to do any editing.
    This is no good because I have to retype the whole test again in the Edit Box for any character change.
3. This problem happen to both Name and Contact Edit Box but no problem with the Memo box.

I suspect I may have to set some options in the Edit Box to allow editing when I click anywhere in the Edit Box.
Appreciate any help on this issue.




eljo

  • Sr. Member
  • ****
  • Posts: 408
Re: Editing text in DBEdit box
« Reply #6 on: June 25, 2020, 03:26:31 pm »
Hi Eljo, I have attached the sample project with some records for testing, unzip both files into a new folder in D: drive to do the testing.
My issue is as follows:
1. From the main form, click the Details button to display each record details in the Details Form.
    The Details Form is set as Show instead of ShowModal so that the records will follow the Main Form record as I scroll the Grid.
2. When I click anywhere in the Name Edit box, I am not able to do any editing.
    I have to highlight the whole Edit Box before it will allow me to do any editing.
    This is no good because I have to retype the whole test again in the Edit Box for any character change.
3. This problem happen to both Name and Contact Edit Box but no problem with the Memo box.

I suspect I may have to set some options in the Edit Box to allow editing when I click anywhere in the Edit Box.
Appreciate any help on this issue.
I'll take a closer look tonight at home.

erictan

  • Jr. Member
  • **
  • Posts: 52
Re: Editing text in DBEdit box
« Reply #7 on: July 03, 2020, 12:53:47 pm »
Hi Eljo, any advice on this issue ?

eljo

  • Sr. Member
  • ****
  • Posts: 408
Re: Editing text in DBEdit box
« Reply #8 on: July 06, 2020, 10:03:27 am »
Hi Eljo, any advice on this issue ?
:o  Sorry I forgot about this   :-[ I added a reminder for tonight but until then try to call the datasource.dataset.edit when the form with the edit controls get focused and datasource.dataset.post when the form with the edit controls looses focus. More specifics tonight.


I'm really sorry about this.

erictan

  • Jr. Member
  • **
  • Posts: 52
Re: Editing text in DBEdit box
« Reply #9 on: July 07, 2020, 05:00:16 pm »
No problem eljo, appreciate your reply.

 

TinyPortal © 2005-2018