Subject Re: [IBO] IB_Edit and computed value.
Author comesailing@btinternet.com
Helen You are a Marvel !
Of course that is the way to do it.
The TTrackbar is a useful slider gadget with graduations where you
can set its Min and Max integer values. So for a person's Height in
cm this is Min = 80 Max = 220 and then the 'value' of the ttrackbar
is the value of it 'position'.
So all I have to do is for the ttrackbar 'on exit'
mydata.fieldbyname('height').asinteger := mytrackbar.position;

Then the value is echoed back into the Ib_Edit. Excellent.
I suppose I may as well use and Ib_Text object instead of an edit
here.
Thanks again
Dave

--- In IBObjects@y..., Helen Borrie <helebor@d...> wrote:
> >So what I need to know is what action normally causes the
Edit.Text to be passed to the dataset ?
>
> I don't know the TTrackbar component but...presumably you already
have a handler on it to calculate the value you want to "transfer to
the IB_Edit".
>
> Remember that it's the dataset fields that give the value to the
IB_Controls, not the other way around. As soon as you give the new
value to the dataset field, it will show up in the IB_Edit (complete
with any masking attributes you have given it at design time). You
don't have to do anything yourself with the control's Text property.
>
> Let's say your handler routine gets a value from the trackbar, does
the calculation and puts a value into MyVariable..and the dataset is
qryMyData...
>
> ....
> with qryMyData do
> begin
> if not(State = dssEdit) then //and maybe other tests
> Edit;
> if State = dssEdit then
> FieldByName('Height').AsFloat := MyVariable
> else
> // fix up whatever is preventing the edit
>
> ...
> ...
>
> >(The dataset is from an ib_query with sql * and 'for update' and
of course the source and 'height' field linked to the ib_edit.)
>
> I still can't get to the bottom of why people want to use the 'for
update' clause in their SQL. I believed FOR UPDATE was only valid
for updating database cursors and wasn't valid in DSQL...but people
do seem to use it in DSQL without getting invalid token errors...I
don't know what it gives you that the encapsulated Edit doesn't; and
it precludes you from using the statement for inserting.
>
> I'm not saying it's wrong: just wondering if it is some
undocumented feature that gives some benefit.
>
>
> >I can use the TTrackbar event of 'on stop drag' to invoke this
action but what is it ? Is is 'lose focus', but the edit has never
had the focus ?! Is it Tab keyed ?
>
> The process you describe here wouldn't require focus, would it?
Presumably, if you don't have the column set READONLY in
ColumnAttributes, the user could still use Tab or the mouse to go to
the control and alter or enter a value, as an alternative or follow-
up to setting the value using the trackbar. In this case, you still
don't have to do anything to make this do the right thing - except to
ensure that the dataset is in Edit mode, of course.
>
> Regards,
> Helen
>
> All for Open and Open for All
> InterBase Developer Initiative ยท http://www.interbase2000.org
> _______________________________________________________