Jump to content

Different Editor in Same Column of DBGrid


bbm

Recommended Posts

  • 5 months later...

Hi, 

 

Do you have any solution for this problem? 

I need to use different control in a same column (edit,combobox, datetimepticker)

Or I have a solution for vcl dbgrid which is perfect for me, but not working with unidbgrid (or i dont know how to archieve it)

my code for vcl 

procedure TForm128.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
  if (gdFocused in State) then
  begin
    if (Column.Field.FieldName = 'variable') then
    begin
       if (ZQuery2.FieldByName('variable_type').AsString = 'text') then
      begin
        variable_datumpicker.Visible := false;
        variable_combobox.Visible := false;
        with variable_edit do
        begin
          Left := Rect.Left + DBGrid1.Left + 2;
          Top := Rect.Top + DBGrid1.Top + 2;

Width := Column.Width;
          Height := Rect.Bottom - Rect.Top;
          variable_edit.Text := ZQuery2.FieldByName('variable_value').AsString;
          Visible := true;
        end;
      end;

etc...

please help me

Thanks

Link to comment
Share on other sites

1 minute ago, Sherzod said:

Please explain.

I mean like in the vcl code :

with variable_edit do
        begin
          Left := Rect.Left + DBGrid1.Left + 2;
          Top := Rect.Top + DBGrid1.Top + 2;

Width := Column.Width;
          Height := Rect.Bottom - Rect.Top;

<< in this case I get the cell canvas rect and can my control cover acutal cell whole canvas.

Like in unidbgrid editor when is showing of the given control you cover whole canvas of that cell,  I tried to get editor's control(edit,combobox) left, top and with.. but didn't work for me, for example only got the original edit's witdh(as placed on form in design mode) , not what dbgrid is showing runtime.    

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...