Hide component in first record (Dbctrlgrid)

Asked

Viewed 448 times

1

Num TDBCtrlGrid I want to hide a component, actually a TPanel only in the first record of dataset.
I tried at the event DBCtrlGrid1PaintPanel checking when the Index = 0 but when for example the first record is selected it ends up showing the control, because the component continues redesigning the records below and changes the Tpanel to visible.
Can you do this? Hide or show a control depending on the index of the record?

2 answers

0

You can use the Dataset Afterscroll event to make the Dashboard Visible or not, it would be like this:

procedure TfrmPrincipal.ClientDataSet1AfterScroll(DataSet: TDataSet);
begin
  Panel1.Visible:= ClientDataSet1.RecNo >1;
end;

So every time the first record is selected in Dbcontrolgrid the Panel will not be visible.

  • It does not work friend, it happens the same, because the records below the first make visible the panel of the first record. I don’t know if it makes a difference, I’ll test it later, but the panel is Align = alTop;

0

Dude I did a test here and I managed to hide a component as follows

procedure TFo_Cadastro_Generico.DBGrid1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
   Me_Busca.Visible:=  Qy_Principal.RecNo <> 1;
end;

In the event dagrid keyup I check if the number of the current record is different from 1 (first) if it is leaves the maskedit search visible, if it is the first leaves the maskedit search invisible.

I hope I have understood your question correctly :) . And I hope I have been clear in my example too :)

Any doubt just talk.

  • Thanks for trying, but I don’t think you understand correctly. Note that it’s not a DBGrid, but rather a DBCtrlGrid. Although they are relatively similar controls, the events and logic to control them are different.

  • Good evening Andrey.. Really, in the eagerness to help I didn’t notice that the object was Dbctrlgrid. I’ve used it a few times.. I really haven’t seen a way to do what you need to do. Sorry and hugs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.