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

Вниз

матрица   Найти похожие ветки 

 
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;
Скачать: CL | DM;

Наверх




Память: 0.46 MB
Время: 0.013 c
2-1315833646
patrick1968
2011-09-12 17:20
2011.12.18
Доступ с правами определенного пользователя


15-1314908994
Юрий
2011-09-02 00:29
2011.12.18
С днем рождения ! 2 сентября 2011 пятница


15-1314544353
alexdn
2011-08-28 19:12
2011.12.18
Переименовать файл в винде


8-1221298606
Grinya
2008-09-13 13:36
2011.12.18
карта в масштабе


2-1315465617
user1987
2011-09-08 11:06
2011.12.18
Вывод текста на рабочий стол