Главная страница
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.009 c
4-1253174465
Edward
2009-09-17 12:01
2011.12.18
Дублируются перехваченные с клавиатуры символы


2-1315383105
Pushok
2011-09-07 12:11
2011.12.18
На форме исчезает TreeView


2-1315384691
yurikon
2011-09-07 12:38
2011.12.18
Имя MSSQL сервера


15-1314396395
alexdn
2011-08-27 02:06
2011.12.18
Программа для видео


2-1315554871
Andrey K
2011-09-09 11:54
2011.12.18
ActiveControl