Главная страница
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.036 c
3-1101282742
NewDelpher
2004-11-24 10:52
2004.12.26
жуткий глюк MS SQL


1-1102972333
STK
2004-12-14 00:12
2004.12.26
Загруженность процессора(100%) процессом(как облегчить)


3-1101980098
intaari
2004-12-02 12:34
2004.12.26
Выбор типа базы данных (Paradox, DBase, FOXPRO или др.)


14-1102404944
slaga
2004-12-07 10:35
2004.12.26
Программирование для мобильных телефонов ?


1-1102596883
Aleksandr.
2004-12-09 15:54
2004.12.26
Люди, ничего уже не понимаю! В чем провинилась ExtractFileName?