Главная страница
    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.45 MB
Время: 0.035 c
10-1071058585
ShimA
2003-12-10 15:16
2004.12.26
DELPHI+CORBA+CALLBACK Самоуничтожение объекта


1-1102874750
Bobby Digital
2004-12-12 21:05
2004.12.26
Glyph


14-1102360367
Alex_Petr
2004-12-06 22:12
2004.12.26
Кто-нибудь сталкивался с фирмой: "Elessta" ?


8-1096175195
Mitay
2004-09-26 09:06
2004.12.26
Как определить частоту?


6-1097676923
Dead Lord
2004-10-13 18:15
2004.12.26
chat





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский