Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2004.12.26;
Скачать: [xml.tar.bz2];

Вниз

Почему к строке 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;
Скачать: [xml.tar.bz2];

Наверх





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


1-1102786407
Frozzen
2004-12-11 20:33
2004.12.26
Спрятать главную форму при создании?


3-1101819424
DuchmanSoft
2004-11-30 15:57
2004.12.26
Много пользовательская база


14-1102496634
DelphiN!
2004-12-08 12:03
2004.12.26
Не подскажите программу форматирования стиля исходников Делфи


14-1102487212
ocean
2004-12-08 09:26
2004.12.26
ДТП





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
Английский Французский Немецкий Итальянский Португальский Русский Испанский