Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 11 to 14 of 14 total |
How to cancel a change to a field? |
Sun, Mar 25 2007 6:30 PM | Permanent Link |
"Adam H." | Hi Ralf,
> if you don't want a user to change a field, then mark it as read only or > disabled. As a user, I'd search tar and feathers for the developer who let > me (not) change something without a hint. Not a bad idea, but at this point in time, it's not that I don't want the user to be able to change the field - I just don't want them to be able to change the field until they've put a few entries into some 'other' fields. Maybe I could use the datasource to check during every onchange event, and mark my field as readonly or not whenever the user changes, but even with a hint, I know my users - they're going to need a message dead in their face, with an OK button or they're just not going to see it. Certainly gives me some food for thought though! Appreciate the suggestion! Cheers Adam. |
Sun, Mar 25 2007 6:30 PM | Permanent Link |
"Adam H." | Hi Sean,
Thanks for your example. I have tried something effectively to what you have suggested. (The only difference being, I used a global variable, instead of the field tag - but I like your idea of the field tag. Much cleaner!) I think I've found part of the problem. Apparently, when the code executes, their is still a tick in the checkbox, but after placing a dbgrid on the screen next to it, I see that the field is changed back to false, even though the checkbox still shows a tick within it. It looks as though this could be a problem with the visual component more than the field from what I can gather. Thanks & Regards Adam. |
Sun, Mar 25 2007 6:38 PM | Permanent Link |
"Adam H." | Hi Ralf,
> What if you put that code in OnChange? You might have to add some test to > avoid an infinite loop, but it should work. Thanks for your suggestion. I was doing something similar to what Sean suggested, but as per my response to Sean, it would appear as though the problem may have something more to do with the DBCheckbox component), more than the value of the field itself. I have the following code set on the onchange event, and have found that it does indeed change the value of the field, but the checkbox remains 'ticked' on the screen, even though the value is reverted back to false. Interesting... if sender.tag = 1 then exit; sender.tag := 1; try if sender.asboolean = true then if not checkbox1.checked then begin showmessage('You can not allow this field to be edited until you tick the "Allow Field to be True" checkbox'); sender.asboolean := false; end; Sender.tag := 0; if sender.value then showmessage('The value for the field is TRUE') else showmessage('The value for the field is FALSE'); except sender.tag := 0; raise; Cheers Adam. |
Fri, Mar 30 2007 2:27 PM | Permanent Link |
Sean McCall | Adam,
I long ago started using my own versions of the VCL components derived from the standards because I didn't like the way the standard controls worked and I can't stand that there are two sets of controls for aware & non-aware components (a legacy from D1 I think when there was no abstract TDataset & DB.PAS unit). I seem to remember that the checkbox has issues with changing the field value - maybe until the user moves off the control. Looking at the source, TDBCustomCheckbox does not override the Click method so I think this is the case. Notice the code in TDBComboBox.Click. Unfortunately Borland made the data links in all their controls private, so the cleanest way of deriving a new components is cut & paste or hacking into protected or private methods & fields. Anyway, since it seems to make a difference for you in only one field, the simplest fix may be: TDBCheckBox.OnClick(ASender: TComponent) var ACheckbox: TDBCheckbox; begin ACheckbox := ASender as TDBCheckbox; {or just reference it directly} ACheckbox.Field.AsBoolean := ACheckbox.Checked; end; {procedure} This will set the field value when the user checks the box. The event for TField.OnChange will then be fired. Sean Adam H. wrote: > Hi Sean, > > Thanks for your example. I have tried something effectively to what you have > suggested. (The only difference being, I used a global variable, instead of > the field tag - but I like your idea of the field tag. Much cleaner!) > > I think I've found part of the problem. Apparently, when the code executes, > their is still a tick in the checkbox, but after placing a dbgrid on the > screen next to it, I see that the field is changed back to false, even > though the checkbox still shows a tick within it. > > It looks as though this could be a problem with the visual component more > than the field from what I can gather. > > Thanks & Regards > > Adam. > > |
« Previous Page | Page 2 of 2 | |
Jump to Page: 1 2 |
This web page was last updated on Saturday, April 27, 2024 at 08:52 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |