Forum > Databases
DBEdit - display setting of number (IBX)
Nicole:
There is a TDBEdit, which allows me to modify a value in my database.
This value is defined there as double.
I change the value within the DBEdit from 1 to 1.05.
My DBEdit lets me key in the 1,05 and it changes as it should.
However on "commit" it displays 1,1.
The value in the database is changed correctly to 1.05.
What can I do, that my TBEdit displays the correct value of 1.05 instead of 1.1?
Thanks.
rvk:
You need to change the TField.Displayformat to include 2 decimals.
https://lazarus-ccr.sourceforge.io/docs/fcl/db/tnumericfield.displayformat.html
For example.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Query.FieldByName('yourfield').DisplayFormat := '#.00';
Nicole:
Thank you for your answer, I searched for something like this, - but cannot find it.
DBEdit has nothing like Field or Display in the Object inspector.
I was told before, that there is a living without the Object Inspector, but as simple girl, I cannot reproduce any more.
I found further a datasource - dataset-query which I (really me?) seemed to have linked to my DBEdit hundred years ago.
But there is not DisplayFormat neither.
So in short: How can I get to this Display Format starting from the DBEdit?
Thanks.
rvk:
--- Quote from: Nicole on June 08, 2023, 05:36:25 pm ---So in short: How can I get to this Display Format starting from the DBEdit?
--- End quote ---
You need to set it in code.
Or, if you have the fields defined, you can set it in the object inspector.
How did you set the field in dbedit?
You can put the code I gave directly below the line where you call open on the query.
If you don't know how, you need to show some code (on how you open the query).
Nicole:
This was the only thing, which worked just by clicking. I have little idea, what happens behind:
I have a DBEdit, a Query and an Update query.
"Above" it, there is a radio-box, where the user (=just me) can choose, which table he wants to edit.
Some table-choices work, others don't. I gave up, because it took too much time.
This choice was the only choice which worked fine, ;-)
The option-chosen we talk about leads to this OnClick-myTableEditbutton:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- If (RadioGroup_bearbeiten.ItemIndex = 5) then // tbwaren begin if RadioGroupEx_bearbeiteWare.ItemIndex > 0 then begin // das sollte ohnehin nie sein können, doch zur Sicherheit ware_:=RadioGroupEx_bearbeiteWare.Items.strings[RadioGroupEx_bearbeiteWare.ItemIndex]; s:=Frame_Waren.KuerzelInWare(ware_); // ware_ brauche ich für die Query unverändert Panel_WareKopf.Caption:='Stammdaten für ' + s; // schreibt z.B. Stammdaten Weizen s:='select * from tbkennzahlen where COMM = :ware_'; s:=s + ' order by COMM'; IBQuery_Ware.SQL.Text:=s; IBQuery_Ware.ParamByName('ware_').AsString:=ware_; IBQuery_Ware.Active:=true; end; end;
There are a lot of input fields and tables this form was inteded to change in my db.
But only one DBEdit, for this specific, it looks like this
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---object DBEdit_LockLimit: TDBEdit Left = 24 Height = 25 Top = 24 Width = 73 DataField = 'DAILY_LIMIT' DataSource = DataSource_Ware AutoSize = False MaxLength = 4 TabOrder = 0end
I hope, this is understandable. If it would be too complex, I leave it like it is.
Navigation
[0] Message Index
[#] Next page