Select part of FieldValue in DBGrid lazarus / 16-Databases ---------------------------------------------------------------------- John Landmesser · 2024-02-21 14:39 i am on Linux and i want to select per code only the hours of: Dataset.FieldByName('Zeit_gelaufen').AsString:= '00:00:00'; Info: Linux manjaro 6.1.71-1-MANJARO #1 SMP PREEMPT_DYNAMIC Fri Jan  5 17:36:36 UTC 2024 x86_64 GNU/Linux Lazarus 3.99 (rev main_3_99-1363-g0d5579dc3f) FPC 3.2.2 x86_64-linux- gtk2 Lots of SendMessage i think? Tipps are welcome ! ---------------------------------------------------------------------- cdbc · 2024-02-21 14:46 Hi If you get a string value back e.g.: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i S:= Dataset.FieldByName('Zeit_gelaufen').AsString;of said format, I'd use:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i hrStr:= S.Split([':'])[1]; Regards Benny ---------------------------------------------------------------------- mig-31 · 2024-02-21 14:49 Hi, to parse a string you can use ExtractDelimited from StrUtil Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ExtractDelimited(2, '00:00:00', [':']); ---------------------------------------------------------------------- John Landmesser · 2024-02-21 14:55 Thanks to both of you that tried to answer my question! But: I don't want to extract something from Field.AsString but preselect the hours - part of the SelectedField! ---------------------------------------------------------------------- cdbc · 2024-02-21 15:09 Hi Then, I'm sorry, I haven't got the foggiest of what you're talking about  Regards Benny ---------------------------------------------------------------------- Zvoni · 2024-02-21 15:14 At a guess (from the Subject-Title and answers here): He wants to Display the hour-part already as "selected" in his DBGrid ---------------------------------------------------------------------- John Landmesser · 2024-02-21 15:16 Think of a Field with EditMask hh:nn:ss. The user usually does not enter the hour part but minutes and seconds . So i want to preselct the minutes Sorry i told you about hours above, that was wrong! ---------------------------------------------------------------------- Zvoni · 2024-02-21 15:19 And how do you expect that to work in a DBGrid? Say, your Grid shows 10 records, and for each record in that column it should preselect the minutes? So you would have 10 preselected partial "Strings" in 10 different cells? ---------------------------------------------------------------------- John Landmesser · 2024-02-21 15:23 I want to do that onNewRecord event: procedure TForm1.ZQuery1NewRecord(DataSet: TDataSet); ---------------------------------------------------------------------- JWBokx · 2024-02-21 15:33 depends on the used editor for the field. THe Editor property is the currentcell editor. But this is a wincontrol, so if a TEdit is used check the classname or classtype for e TEdit descendent. In a TEdit the proprties to select a part is SelStart and SelLength. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  start, len: integer; beginstart:=Pos(':',DBGrid.SelectedField.asstring,1);len :=Pos(':',DBGrid.SelectedField.asstring,2) - start; (DBGrid.Editor as Tedit).SelStart:=start;(DBGrid.Editor as Tedit).SelLength:=len; ...    (Not tested just an idea!) ---------------------------------------------------------------------- John Landmesser · 2024-02-21 15:37 Thank you , i will test that because i think that could be a solution :-) ---------------------------------------------------------------------- John Landmesser · 2024-02-21 18:02 I think i try tomorrow  and hopefully learn how to do it: See: https://wiki.lazarus.freepascal.org/Grids_Reference_Page#procedure_Inp laceEditor If i have no success, i have to hit 0 twice to get to the minutes ... pure horror !