 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Chris L. Guest
|
Posted: Fri Jan 23, 2004 7:11 pm Post subject: TDataSet.Delete Question |
|
|
Hi All,
I have DBGrids displaying data from TTables and TQuerys .
I want to display my own exception error message when user deletes records
using keystroke (Ctrl + Del). This happens when the TTable and TQuery is
empty.
The error message will read "TTablename: Cannot perform this operation on an
empty dataset. "
I want to specify the TTablename so that the message is more readily
undetstood. How can I do that?
Thanks.
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ([url]http://www.grisoft.com)[/url].
Version: 6.0.558 / Virus Database: 350 - Release Date: 1/2/2004
|
|
| Back to top |
|
 |
Dan Guest
|
Posted: Fri Jan 23, 2004 8:25 pm Post subject: Re: TDataSet.Delete Question |
|
|
On Fri, 23 Jan 2004 19:11:20 GMT, "Chris L."
<christopher.leongc (AT) verizon (DOT) net> wrote:
| Quote: | Hi All,
I have DBGrids displaying data from TTables and TQuerys .
I want to display my own exception error message when user deletes records
using keystroke (Ctrl + Del). This happens when the TTable and TQuery is
empty.
The error message will read "TTablename: Cannot perform this operation on an
empty dataset. "
I want to specify the TTablename so that the message is more readily
undetstood. How can I do that?
Thanks.
You might get what you want by setting KeyPreview for the form to |
true. Then, in the OnKeyDown event handler check for ctrl-del. If
true, check for the grid having focus and the dataset being empty.
Then show your message. Returning from the message, throw away the
keystroke (Key := 0;)
email me if you need a code sample.
HTH,
Dan
|
|
| Back to top |
|
 |
Chris L. Guest
|
Posted: Fri Jan 23, 2004 9:15 pm Post subject: Re: TDataSet.Delete Question |
|
|
Dan,
I apologize for not making my situation clear. I have a main form which
hosts a number of TFrames. The DBGrids are in the TFrames. So, if a user
presses Ctrl+Del, he'll be doing it inside a TFrame, which does not have
KeyPreview property. Propergating it to the main form get a little bit
complicated, because I would have to check which TFrame is visible and in
focus.
My TTables and TQuerys are on a TDataModule. I was hoping I can write the
code to handel Ctrl+Del in the TDataModule.
Would you have any suggestions?
Chris
"Dan" <Doculus at CMDCsystems dot com> wrote
| Quote: | On Fri, 23 Jan 2004 19:11:20 GMT, "Chris L."
[email]christopher.leongc (AT) verizon (DOT) net[/email]> wrote:
Hi All,
I have DBGrids displaying data from TTables and TQuerys .
I want to display my own exception error message when user deletes
records
using keystroke (Ctrl + Del). This happens when the TTable and TQuery is
empty.
The error message will read "TTablename: Cannot perform this operation on
an
empty dataset. "
I want to specify the TTablename so that the message is more readily
undetstood. How can I do that?
Thanks.
You might get what you want by setting KeyPreview for the form to
true. Then, in the OnKeyDown event handler check for ctrl-del. If
true, check for the grid having focus and the dataset being empty.
Then show your message. Returning from the message, throw away the
keystroke (Key := 0;)
email me if you need a code sample.
HTH,
Dan
|
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ([url]http://www.grisoft.com)[/url].
Version: 6.0.558 / Virus Database: 350 - Release Date: 1/2/2004
|
|
| Back to top |
|
 |
Dan Guest
|
Posted: Fri Jan 23, 2004 10:28 pm Post subject: Re: TDataSet.Delete Question |
|
|
On Fri, 23 Jan 2004 21:15:27 GMT, "Chris L."
<christopher.leongc (AT) verizon (DOT) net> wrote:
| Quote: | Dan,
I apologize for not making my situation clear. I have a main form which
hosts a number of TFrames. The DBGrids are in the TFrames. So, if a user
presses Ctrl+Del, he'll be doing it inside a TFrame, which does not have
KeyPreview property. Propergating it to the main form get a little bit
complicated, because I would have to check which TFrame is visible and in
focus.
My TTables and TQuerys are on a TDataModule. I was hoping I can write the
code to handel Ctrl+Del in the TDataModule.
Would you have any suggestions?
Chris
Look up TDataSet.OnDeleteError. In here you can control the error |
message. Set the Action to daAbort, then add your own message. if you
want any. I suspect the user doesn't really need or want a popup
message to have to clear.
I haven't tried this, but it should be what you need.
Dan
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|