Главная страница
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.031 c
15-1164236733
Стример
2006-11-23 02:05
2006.12.10
Скажите. в Линуксе есть dll и IStream ?


1-1161943972
Alex_C
2006-10-27 14:12
2006.12.10
Как реализовать метод SelLength в своем мемо?


15-1163760410
untermensch
2006-11-17 13:46
2006.12.10
В чём щас помосчь пишется ?


15-1164095160
boriskb
2006-11-21 10:46
2006.12.10
А вы говорите: "Злые розыгрыши"


15-1163963893
radium
2006-11-19 22:18
2006.12.10
Как побороть троян?