Recent

Author Topic: Dataset.FloatField and DBGrid  (Read 1644 times)

Jupp Schmitz

  • Newbie
  • Posts: 1
Dataset.FloatField and DBGrid
« on: November 12, 2018, 10:45:24 pm »
Hello People,

I have a simple Form with
Dataset -> DataSource -> DBGrid

Dataset has a Floatfield.
DBGrid allows only Floatvalues('0..9' and ',') to be entered. (where/when is this established? Editmask of Dataset.Field is empty.)

I want the user to be able to insert fractions like '5/3' in the DBGrid and then calculate the Value by my own 'OnBeforePost' of Dataset or 'OnUpdateData' of DataSource(wich one or other is right?).

Ok, i can use a Stringfield instead of a FloatField, but then i have to convert and check everytime i use the Field in other Units/Functions...

Or are TField.GetText and TField.SetText the Events for me?
Or TField.OnValidate?

Tryed a lot - nothing works?!

thank's in advance
A Jupp

madref

  • Hero Member
  • *****
  • Posts: 949
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: Dataset.FloatField and DBGrid
« Reply #1 on: November 13, 2018, 08:28:50 am »
Here is just an idea.
Make a text field where you can put anything in
check if the input is valid
then convert that to your float and store in in your float field (which is invisible)
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 3.99 (rev main_3_99-649-ge13451a5ab) FPC 3.3.1 x86_64-darwin-cocoa
Mac OS X Monterey

 

TinyPortal © 2005-2018