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

Вниз

Почему к строке StringGrid нельзя применить Delete?   Найти похожие ветки 

 
dr Tr0jan   (2004-12-14 09:53) [0]

StringGrid1.Cols[0].Delete(1) - не работает, как обойти?


 
ssk ©   (2004-12-14 09:57) [1]

когда-то давно где-то в инете нашел такой модуль:


unit GridFunc;

interface

uses
Sysutils, WinProcs, Grids;

procedure InsertRow   (Sender: TStringGrid; ToIndex: Longint);
procedure DeleteRow   (Sender: TStringGrid; FromIndex: Longint);
procedure InsertColumn(Sender: TStringGrid; ToIndex: Longint);
procedure DeleteColumn(Sender: TStringGrid; FromIndex: Longint);

implementation

type
TCSGrid = class(TStringGrid)
private
public
procedure MoveRow   (FromIndex, ToIndex: Longint);
procedure MoveColumn(FromIndex, ToIndex: Longint);
end;

procedure TCSGrid.MoveRow(FromIndex,ToIndex: Longint);
begin
RowMoved(FromIndex, ToIndex); { Защищенный метод TStringGrid }
end;

procedure TCSGrid.MoveColumn(FromIndex, ToIndex: Longint);
begin
ColumnMoved(FromIndex, ToIndex);{ Защищенный метод TStringGrid }
end;

procedure InsertRow(Sender: TStringGrid; ToIndex: Longint);
var
xx,yy: Integer;
begin
if ToIndex>=0 then
with TCSGrid(Sender) do
if (ToIndex<=RowCount) then
begin
RowCount := RowCount + 1;
xx := RowCount - 1;
for yy := 0 to ColCount - 1 do
begin
Cells[yy,xx] := " ";
ObJects[yy,xx] := nil;
end;
if ToIndex<RowCount-1 then
MoveRow(RowCount-1,ToIndex);
end
else
MessageBeep(0)
else
MessageBeep(0);
end;

procedure DeleteRow(Sender: TStringGrid; FromIndex: Longint);
begin
if FromIndex>0{;=0} then
with TCSGrid(Sender) do
if (RowCount>0)and(FromIndex<RowCount) then
begin
if (FromIndex<RowCount-1) then
MoveRow(FromIndex,RowCount-1);
Rows[RowCount-1].Clear;
RowCount := RowCount-1;
end
else
MessageBeep(0)
else
MessageBeep(0);
end;

procedure InsertColumn(Sender: TStringGrid; ToIndex: Longint);
var
xx,yy: Integer;
begin
if ToIndex>=0 then
with TCSGrid(Sender) do
if (ToIndex<=ColCount) then
begin
ColCount := ColCount + 1;
xx := ColCount - 1;
Cols[xx].BeginUpdate;
for yy := 0 to RowCount - 1 do
begin
Cells[xx,yy] := " ";
ObJects[xx,yy] := nil;
end;
Cols[xx].EndUpdate;
if ToIndex<ColCount-1 then
MoveColumn(ColCount-1,ToIndex);
end
else
MessageBeep(0)
else
MessageBeep(0);
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
else
MessageBeep(0)
else
MessageBeep(0);
end;

end.


 
Leonid Troyanovsky ©   (2004-12-14 10:05) [2]


> dr Tr0jan   (14.12.04 09:53)  
> StringGrid1.Cols[0].Delete(1) - не работает, как обойти


type
 THackGrid = class(TStringGrid);

procedure TForm1.Button1Click(Sender: TObject);
begin
 with THackGrid(StringGrid1) do DeleteColumn(0);
end;


--
С уважением, LVT.


 
dr Tr0jan   (2004-12-14 10:53) [3]

Большое спасибо



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

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

Наверх




Память: 0.47 MB
Время: 0.024 c
1-1103096865
Змей
2004-12-15 10:47
2004.12.26
DriveCombobox


4-1099737740
acsoft
2004-11-06 13:42
2004.12.26
Открывать txt моей программой


1-1102537599
Homa_Programer
2004-12-08 23:26
2004.12.26
mailto:


1-1103032241
alex145
2004-12-14 16:50
2004.12.26
DUPLICATE RESORCE


6-1097472068
Slonco
2004-10-11 09:21
2004.12.26
В отправленном письме абракадабра...