Hello, members of the forum, I have the following question on Delphi. In DBGride there is a sequence number column, and it is filled with 1, 2, 3 ... etc. And is it possible to display the last line of this column in label?
- or how to make it impossible to repeat the same number in the column? - alexandr91
- The number of records, what to display? Then, for this, the DBGrid itself is not needed, but the method of its data set (table or query) * Table.RecordCount; - DelphiM0ZG
- No, for example, in DBGride, the last entry in the column "serial number" is 45, so I need to output 45 in the lable. If I add the following entry with the number 80, it should replace 45 with 80 in the lable. - alexandr91
|
2 answers
The last row of a column with a sequence number can be displayed as follows:
procedure TForm1.ADOTable1AfterPost(DataSet: TDataSet); begin ADOTable1.Last; Label1.Caption:=ADOTable1.Fields[5].AsString; // у Вас будет свой номер столбца ADOTable1.First; // в начало, можно не переходить, если не нужно end;
This is the OnAfterPost data set handler (that is, it will output after saving).
|
Make the output of the last record by Table.RecordCount, output the field that contains your "45" FieldByName (column_name) .Value DBText, well, or in a label. IntToStr (Table1.RecNo) - you can also find out the total number of records, hence the sequence number of the last one, to output its values by fields. And I did it easier:
table1.Last; label2:=Table1.FieldByName('Имя_поля_в_котором_значение').Value; table1.First
|