0

I want to set the caret position in my derived TInplaceEdit in a derived DBGrid, similiar to a TDBGrid for right aligned columns.

procedure TMyGridEditor.CreateParams(var Params: TCreateParams);
const
  Alignments : array[TAlignment] of LongWord= (ES_Left, ES_Right, ES_Center);
begin
  inherited CreateParams(Params);
  Params.Style := Params.Style or Alignments[FAlignment];
end;

procedure TMyGridEditor.UpdateContents;
begin
  inherited;
  // if Assigned(Grid) and Assigned(Grid.SelectedColumn) then begin
  //  Alignment := Grid.SelectedColumn.Alignment;
  if (TDBGrid(Grid).SelectedIndex <> -1) then 
    Alignment := TDBGrid(Grid).Columns[TDBGrid(Grid).SelectedIndex].Alignment;
end;

Additional description:

Grid.SelectedColumn = Currently selected column of the grid

Sample picure: Column too small for value

Problem1: The caret position is always on the right and positioned after the last character, this looks strange for ie. string and memo contents. How can I set the caret to the left, just after the inplaceeditor will be displayed.

Problem2: The contents for number values are displayed on multiple lines, when there is not sufficient space avaiable (column is too small). This looks very strange.

How can I accomplish these tasks? Any help appreciated... Thanks

mumu
  • 11
  • 1
  • 1
    These are two very separate issues. The first is to do with your custom editor and the second to do with your grid. Both require very different answers. I suggest that you split your question into two separate ones so that they can be answered individually. – Dsm Jun 28 '17 at 08:52
  • Thank you very much, but I am new and not allowed to post more than one question yet. Grid.SelectedColumn is the current selected column of the grid. – mumu Jun 28 '17 at 11:19
  • Then how does your code determine which column is selected, using `SelectedIndex` or what? – MartynA Jun 28 '17 at 11:23
  • Modified the UpdateContents method to clarify the subject – mumu Jun 28 '17 at 12:18

0 Answers0