Форум: "Начинающим";
Текущий архив: 2011.12.18;
Скачать: [xml.tar.bz2];
Внизматрица Найти похожие ветки
← →
OW © (2011-09-08 12:48) [10]unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
procedure FormCreate(Sender: TObject);
private { Private declarations }
public { Public declarations }
end;
type
TCSGrid = class(TStringGrid)
private
public
procedure MoveRow(FromIndex, ToIndex: Longint);
procedure MoveColumn(FromIndex, ToIndex: Longint);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TCSGrid.MoveRow(FromIndex, ToIndex: Longint);
begin
RowMoved(FromIndex, ToIndex);
end;
procedure TCSGrid.MoveColumn(FromIndex, ToIndex: Longint);
begin
ColumnMoved(FromIndex, ToIndex);
end;
procedure DeleteRow(Sender: TStringGrid; FromIndex: Longint);
begin
if FromIndex > 0
then
with TCSGrid(Sender) do
if (RowCount > 2) and (FromIndex < RowCount) then
begin
if (FromIndex < RowCount - 1) then
MoveRow(FromIndex, RowCount - 1);
Rows[RowCount - 1].Clear;
RowCount := RowCount - 1;
end
end;
procedure DeleteColumn(Sender: TStringGrid; FromIndex: Longint);
begin
if FromIndex >= 0 then
with TCSGrid(Sender) do
if (ColCount > 0) and (FromIndex < ColCount) then
begin
if (FromIndex < ColCount - 1) then
MoveColumn(FromIndex, ColCount - 1);
Cols[ColCount - 1].Clear;
ColCount := ColCount - 1;
end
end;
procedure TForm1.FormCreate(Sender: TObject);
var
i,j: Integer;
begin
StringGrid1.RowCount := 9;
StringGrid1.ColCount := 9;
for i:= 0 to StringGrid1.RowCount - 1 do
for j := 0 to StringGrid1.ColCount - 1 do
StringGrid1.Cells[i,j] := IntToStr(i+j*10);
// удалим 4-ю строку
DeleteRow(StringGrid1, 4);
// удалим 7-ю столбец
DeleteColumn(StringGrid1, 7);
end;
end.
Страницы: 1 вся ветка
Форум: "Начинающим";
Текущий архив: 2011.12.18;
Скачать: [xml.tar.bz2];
Память: 0.44 MB
Время: 0.004 c