Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: DBGrid cancels insert when focus moved to another data-bound control - why?


This question is answered.


Permlink Replies: 3 - Last Post: Nov 23, 2016 10:47 PM Last Post By: Andrew Smith
Andrew Smith

Posts: 2
Registered: 7/14/03
DBGrid cancels insert when focus moved to another data-bound control - why?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 20, 2016 9:17 PM
Hi all,

Using Berlin Update 2. I have a simple config screen which has a DBGrid linked to a dataset to show a list of all entries present. I also have a DBNavigator and DBEdit box on the form to allow users to create new records and enter data. If the user clicks on the edit box and then inserts a record, the insert works and they can type in a new value. If they focus the grid first and then insert a record via the navigator, when they click on the edit box to enter some data the dataset's Cancel method is called. Is this intended behaviour? If you move focus from one data-aware control to another which is linked to the same dataset, there should be no reason to cancel a pending insert. In fact, if the DBEdit has focus and an insert is performed and I then move focus to a different control on the form, the insert is not cancelled. So why does it happen with the DBGrid? Note that in XE6 (version I have just upgraded from) the grid did not behave this way.

Cheers,

Andrew
Jeff Overcash (...

Posts: 1,529
Registered: 9/23/99
Re: DBGrid cancels insert when focus moved to another data-bound control - why?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 21, 2016 10:24 AM   in response to: Andrew Smith in response to: Andrew Smith
Andrew Smith wrote:
Hi all,

Using Berlin Update 2. I have a simple config screen which has a DBGrid linked to a dataset to show a list of all entries present. I also have a DBNavigator and DBEdit box on the form to allow users to create new records and enter data. If the user clicks on the edit box and then inserts a record, the insert works and they can type in a new value. If they focus the grid first and then insert a record via the navigator, when they click on the edit box to enter some data the dataset's Cancel method is calle
d. Is this intended behaviour? If you move focus from one data-aware control to another which is linked to the same dataset, there should be no reason to cancel a pending insert. In fact, if the DBEdit has focus and an insert is performed and I then move focus to a different control on the form, the insert is not cancelled. So why does it happen with the DBGrid? Note that in XE6 (version I have just upgraded from) the grid did not behave this way.

Cheers,

Andrew

IIRC DBGrid has always canceled an insert if nothing was modified when it loses
focus. I tested back to XE5, but I think it has always been this way with DBGrid.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Learning is finding out what you already know. Doing is demonstrating that you
know it. Teaching is reminding others that they know it as well as you. We are
all leaners, doers, teachers. (R Bach)
Achim Kalwa

Posts: 70
Registered: 10/22/99
Re: DBGrid cancels insert when focus moved to another data-bound control - why?
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 21, 2016 11:37 PM   in response to: Andrew Smith in response to: Andrew Smith
Hello Andrew,

[...]
If they focus the grid first and then insert a record via
the navigator, when they click on the edit box to enter some data the
dataset's Cancel method is calle d. Is this intended behaviour? If
you move focus from one data-aware control to another which is linked
to the same dataset, there should be no reason to cancel a pending
insert. In fact, if the DBEdit has focus and an insert is performed
and I then move focus to a different control on the form, the insert
is not cancelled. So why does it happen with the DBGrid? Note that in
XE6 (version I have just upgraded from) the grid did not behave this
way.

Have a look at DBGrid's Options: There is dgCancelOnExit, which is
enabled by default. Try to remove that.

HTH
Achim
Andrew Smith

Posts: 2
Registered: 7/14/03
Re: DBGrid cancels insert when focus moved to another data-bound control - why?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 23, 2016 10:47 PM   in response to: Achim Kalwa in response to: Achim Kalwa
Achim Kalwa wrote:
Hello Andrew,

[...]
If they focus the grid first and then insert a record via
the navigator, when they click on the edit box to enter some data the
dataset's Cancel method is calle d. Is this intended behaviour? If
you move focus from one data-aware control to another which is linked
to the same dataset, there should be no reason to cancel a pending
insert. In fact, if the DBEdit has focus and an insert is performed
and I then move focus to a different control on the form, the insert
is not cancelled. So why does it happen with the DBGrid? Note that in
XE6 (version I have just upgraded from) the grid did not behave this
way.

Have a look at DBGrid's Options: There is dgCancelOnExit, which is
enabled by default. Try to remove that.

HTH
Achim

That was it, can't believe I didn't notice it! The XE6 code I had was setting that option somewhere that wasn't obvious. Thanks!
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02