Home > Back-end >  After HideRow AdvStringGrid in TMS control problem, reoccupy GetCheckBoxState get in the right state
After HideRow AdvStringGrid in TMS control problem, reoccupy GetCheckBoxState get in the right state

Time:09-22

The code is as follows:

 Procedure TForm1. FormCreate (Sender: TObject); 
Var
I: Integer;
The Begin
With Form1. Advstrngrd1 Do
The Begin
Cells [0, 0] :='ID'.
Cells (1, 0] :='a';
Cells (2, 0] :='2';
Cells (3, 0] :='three';
Cells (4, 0] :='4';
The End;

//set the column 1
With Form1. Advstrngrd1 Do
The Begin
Cells (1, 1] :='5';
Cells: [1, 2]='1';
Cells (1, 3] :='2'.
Cells [1, 4] :='3';
Cells [1, 5] :='4';
Cells [1, 6] :='9'.
Cells [1, 7] :='6';
Cells (1, 8] :='7';
Cells [1, 9] :='8';
The End;
//set the column 2
With Form1. Advstrngrd1 Do
The Begin
Cells (2, 1] :='05:00:05';
Cells (2, 2] :='02:06:05';
Cells (2, 3] :=';
Cells (2, 4] :='6';
Cells (2, 5] :='5';
Cells (2, 6] :=';
Cells (2, 7] :='2'.
Cells (2, 8] :='9';
Cells [2, 9] :='8';

The End;
For I:=1 To 9 Do
The Begin

//set column 4 whole column to the checkbox (column, line, the default is selected,)
Form1. Advstrngrd1. AddCheckBox (4, I, False, False);

The End;
The End;

Procedure TForm1. Btn2Click (Sender: TObject);//hide the line
The Begin
Form1. Advstrngrd1. HideRow (1);
Form1. Advstrngrd1. HideRow (2);
The End;

Procedure TForm1. Btn7Click (Sender: TObject);
Var
Flag: a Boolean;
I: Integer;
Zhi: String;
The Begin
//sorted find corresponding lines
For I:=1 To form1. Advstrngrd1. Do the RowCount - 1
The Begin
Zhi:=Form1. Advstrngrd1. Cells [0, I];
If zhi='5' Then
The Begin
Form1. Advstrngrd1. GetCheckBoxState (4, I, flag);
If flag Then
ShowMessage (' column 3 behavior selected state, 5 lines' + inttostr (I))
The Else
ShowMessage (' column 3 behavior was not selected state, 5 lines' + inttostr (I));
The End;
If zhi='7' Then
The Begin
Form1. Advstrngrd1. GetCheckBoxState (4, I, flag);
If flag Then
ShowMessage (' column 3 behavior selected state, 7 lines' + inttostr (I))
The Else
ShowMessage (' column 3 behavior was not selected state, 7 lines' + inttostr (I));
The End;
The End;
For I:=1 To form1. Advstrngrd1. Do the RowCount - 1
The Begin
Form1. Advstrngrd1. GetCheckBoxState (4, I, flag);
If flag Then
ShowMessage (' column in the first 3 + inttostr (I) + 'behavior selected state, line' + inttostr (I))
The Else
ShowMessage (' column in the first 3 + inttostr (I) + 'behavior was not selected state, line' + inttostr (I));
The End;
The End;


SortSettings sorting is opened
The question now is, when the hidden part of the line to get the checkbox state, be not correct,
To ask you, have what good method? Because I need to provide user sorting and hidden features, at the same time, the software implementation, need according to the first column of the ID of the line, write data to tables,

CodePudding user response:

Can turn to hide the line height is set to 0, RowHeights: [I]=0;
  • Related