convert this TFooDBGrid(DBGrid1).InplaceEditor.EditText) in lazarus lazarus / 31-LCL ---------------------------------------------------------------------- laguna · 2012-10-09 06:39 is possible convert this in lazarus // TFooDBGrid = class(TDBGrid);  if Pos(',', TFooDBGrid(DBGrid1).InplaceEditor.EditText) > 0 then Key := chr(0); This change key '.' on ',' for numeric key on Italian decimal Thanks   TCustomGrid = class(TCustomControl)   on Lazarus   property InplaceEditor: TWinControl read FEditor;   on Delphi   FInplaceEdit: TInplaceEdit;   function CreateEditor: TInplaceEdit; virtual;   property InplaceEditor: TInplaceEdit read FInplaceEdit; ---------------------------------------------------------------------- taazz · 2012-10-09 08:02 no it does not, it checks if the decimal separator is already in the editor and if it is it does not allow it to be keyed in again. ---------------------------------------------------------------------- laguna · 2012-10-09 08:10 I'm sorry, but I do not understand what to do! you may indicate step by step. Thanks for everything ---------------------------------------------------------------------- taazz · 2012-10-09 08:15 The code you have given does not change anything if it is part of a keypress event then it does how ever stop the user for keying in a second ',' in the editor. ---------------------------------------------------------------------- laguna · 2012-10-09 08:31 This procedure works correctly in delphi procedure TfrmPrimaNota.DbGrid1KeyPress(Sender: TObject; var Key: char); begin   if (UpperCase(dbgrid1.SelectedField.FieldName) = 'IMPORTO') then   begin if Key = '.' then Key := ',';       if Key = ',' then          if Pos(',', TFooDBGrid(DBGrid1).InplaceEditor.EditText) > 0 then Key := chr(0);       if Key = '-' then          if Pos('-', TFooDBGrid(DBGrid1).InplaceEditor.EditText) > 0 then Key := chr(0);       if not (Key in ['0'..'9', '-', ',', #8]) then Key := chr(0); end;       end; I need to prevent the user to press several times ',' I check if there is ',' if there is, I cancel button is pressed. with "TFooDBGrid(DBGrid1).InplaceEditor.EditText"I access the current value of the cell, like a TextBox in delphi In keypress get value text cell ---------------------------------------------------------------------- taazz · 2012-10-09 08:35 Can you show the code to create the inplace editor? or even better can you provide a small sample application. The code you have shown so far should work it is after all a key press handler. ---------------------------------------------------------------------- laguna · 2012-10-09 08:50 I'm sorry for my bad English The problem is in the class grid, which is not implemented as in delphi. The keyPress function properly. with the function S: = TFooDBGrid (DBGrid1). InplaceEditor.EditText; load the value "44.03" before entering the character, as in a TextBox that is different from the value given by dbgrid1.SelectedField.AsString work in progress in the cell. "dbgrid1.SelectedField.AsString" returns the value acuisito and not the course of machining. If the cell has a value of 123.44 and I change the value without leaving the cell, "dbgrid1.SelectedField.AsString" semrpe returns the value 123.44, after changing cell'll see the new value. ---------------------------------------------------------------------- taazz · 2012-10-09 09:31 I don't what is the foobargrid how it is sub classed and what kind of editor is the inplace editor.Those are pieces of the puzzle that are needed for a correct diagnosis of the problem. In your latest post you seem to indicate that the problem is that the InplaceEditor.EditText does not return the text in the editor but the text in field. Try to read the InplaceEditor.Text property instead. That should always contain the current editing value. Again DBGrid does not have an InplaceEditor property so I'm just shooting in the dark here. ---------------------------------------------------------------------- laguna · 2012-10-09 09:42 Quote from: taazz on October 09, 2012, 11:31:39 amTry to read the InplaceEditor.Text property instead. That should always contain the current editing value. Property  InplaceEditor.Text  not exist in lazarus This message error: Error: identifier idents no member "text"   TCustomGrid = class(TCustomControl)   in Lazarus   property InplaceEditor: TWinControl read FEditor;   in Delphi   FInplaceEdit: TInplaceEdit;   function CreateEditor: TInplaceEdit; virtual;   property InplaceEditor: TInplaceEdit read FInplaceEdit; ---------------------------------------------------------------------- taazz · 2012-10-09 10:16 All TcustomGrid descendants have a property named Editor it is protected though so you need to either subclass dbgrid your self and make it public or use a small hack to access it eg. Code: [Select]Implementation type   THAckDBGrid = class(TDBGrid)   end; procedure TfrmPrimaNota.DbGrid1KeyPress(Sender: TObject; var Key: char); begin   if (UpperCase(dbgrid1.SelectedField.FieldName) = 'IMPORTO') then   begin if Key = '.' then Key := ',';       if Key = ',' then          if Pos(',', THackDBGrid(TFooDBGrid(DBGrid1)).Editor.Text) > 0 then Key := chr(0);       if Key = '-' then          if Pos('-', TFooDBGrid(DBGrid1).InplaceEditor.EditText) > 0 then Key := chr(0);       if not (Key in ['0'..'9', '-', ',', #8]) then Key := chr(0);   end;     end; I am not sure if this is going to work though you might need to alter more things. I don't have time to check the keyboard handling for each editor to make sure that it passes everything to the grid. You have to do it your self. ---------------------------------------------------------------------- laguna · 2012-10-09 15:44 The property ". Editor.text" is not present. According mè you should rebuild the class as it is in delphi!