Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2006.12.10;
Скачать: CL | DM;

Вниз

Как правильно удалить Строку в StringGrid?   Найти похожие ветки 

 
koha ©   (2006-11-24 15:10) [0]

Могу удалить вот так StringGrid1.Rows[index].Clear;  - Но клетки не исчезают и приходится строки перетаскивать.

Как удалить целиком строку в середине "сетки".
И почему не получается так:
StringGrid1.Rows[index].Delete(index)


 
koha ©   (2006-11-24 15:36) [1]

Точнее сформулирую вопрос.  
> Могу удалить вот так StringGrid1.Rows[index].Clear;  - Но клетки не
> исчезают и приходится строки перетаскивать.

Как удалить строку, чтобы строки не перетаскивать?
Есть ли другой способ?


 
Elen ©   (2006-11-24 15:39) [2]


> koha

Лови :
unit Unit1;

interface

uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, OleCtnrs, Grids, StdCtrls;

type
 TForm1 = class(TForm)
   StringGrid1: TStringGrid;
   Button1: TButton;
   procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
     Rect: TRect; State: TGridDrawState);
   procedure Button1Click(Sender: TObject);

 private
   { Private declarations }
 public
   { Public declarations }
 end;

var
 Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
 Rect: TRect; State: TGridDrawState);
begin
if arow=0 then StringGrid1.RowHeights[arow]:=0;
end;

//********** FUNCTION **********
function DelRowInStringGrid(Grid:TStringgrid;index:integer):variant;
var
i: integer;
begin

Grid.Row:=0;
i:=0;
while( i<=Grid.RowCount - 1)and(  Grid.Row<Grid.RowCount-1) do
begin
if i>=index then begin
  Grid.Rows[i].Assign(Grid.Rows[i+1]);
end else
 Grid.Row:=Grid.Row+1;
 inc(i);
end;
 // StringGrid1.RowCount := StringGrid1.RowCount - 1;
end;
//********** END FUNCTION ******

procedure TForm1.Button1Click(Sender: TObject);
begin
DelRowInStringGrid(StringGrid1,2);
end;

end.


Пробуй


 
koha ©   (2006-11-24 15:57) [3]

Спасибо - принцип понял


 
Германн ©   (2006-11-24 17:12) [4]


> Как удалить строку, чтобы строки не перетаскивать?
> Есть ли другой способ?

У предка TSringGrid есть метод DeleteRow. Значит можно им воспользоваться.



Страницы: 1 вся ветка

Текущий архив: 2006.12.10;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.035 c
8-1146034876
Devider
2006-04-26 11:01
2006.12.10
Изменение размера изображения при видеозахвате.


15-1163547102
nemo2
2006-11-15 02:31
2006.12.10
a dot b = |a||b|cos(a,b)= Ax*Bx + Ay*By + Az*Bz Почему ?


2-1163691278
Lesorub
2006-11-16 18:34
2006.12.10
сокеты и web service


2-1163674438
*Ray*
2006-11-16 13:53
2006.12.10
обнуление значения DBLookUpComboBox


2-1164370211
koha
2006-11-24 15:10
2006.12.10
Как правильно удалить Строку в StringGrid?