Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Delphi: Общие вопросы > Таблица со списками


Автор: WhiteSNAKE 4.8.2006, 18:20
Приветствую! Подскажите, как мне создать таблицу в которой ячейки будут как ComboBox, т.е. реализовать выбор значения ячейки. 

Автор: Guedda 4.8.2006, 19:09
Есть такой компонент CheckListBox. он как раз тебе и нужен.

Автор: dumb 4.8.2006, 19:15
скорее уж TValueListEditor

Автор: Guedda 4.8.2006, 19:17
Цитата(dumb @  4.8.2006,  20:15 Найти цитируемый пост)
TValueListEditor

Можно и его... Запамятовал про него совсем...  

Автор: WhiteSNAKE 4.8.2006, 22:34
Не-а, это не подходитsmile Мне нужно  Заполнение полей таблицы через выпадающий список (как на этой картинке (в фотошопе сделал))user posted image

Добавлено @ 22:37 
user posted image

Автор: Albinos_x 4.8.2006, 22:51
вставляй в StringGrid ComboBox

пример кода. Combobox вставится в ячейку 1,1  
 
Код
... procedure TForm1.FormCreate(Sender: TObject);  
  var  
  R:TRect;  
 Combobox:TCombobox;  
 begin  
 //создаём компанент  
  MyCombobox:=Tcombobox.Create(self);  
  MyCombobox.Parent:=form1;  
  // вставляем  
 StringGrid1.Objects[1,1]:=Combobox;//bsSkinComboBox1;  
  StringGrid1.Objects[1,1].AfterConstruction;  
 R:= StringGrid1.CellRect(1, 1);  
 if (StringGrid1.Objects[1, 1] is TControl) then  
    with TControl(StringGrid1.Objects[1, 1]) do  
        // если размер ячейки не равен 0, то делаем его невидимым  
         if R.Right = R.Left then 
           Visible:=false  
           else  
            begin  
            // иначе рисуем его  
            InflateRect(R, -1, -1);  
            OffsetRect(R, StringGrid1.Left+1, StringGrid1.Top+1);  
            BoundsRect:=R;  
            // делаем компонент видимым  
            Visible:=true;  
            end;  
 end;  
 

Автор: WhiteSNAKE 4.8.2006, 23:32
На 11-ой строчке (StringGrid1.Objects[1,1].AfterConstruction;) появляется CPU window, а затем и ошибка smile 

Или это я - того... (новичек в смыслеsmile 

Автор: Albinos_x 5.8.2006, 00:47
Цитата(WhiteSNAKE @  4.8.2006,  23:32 Найти цитируемый пост)
На 11-ой строчке (StringGrid1.Objects[1,1].AfterConstruction;) появляется CPU window, а затем и ошибка

У меня всё нормально работает, вот немного преобразовал:
Код

// процедура вставки ComboBox
// Grid - StringGrid в который вставляется ComboBox
// ACol, ARow - адрес ячейки в которую вставить ComboBox
procedure ComboboxInStringGrid(var Grid:TStringGrid; ACol, ARow:Integer);
 var
  R:TRect;
  Combobox:TCombobox;
begin
Combobox:=Tcombobox.Create(nil);
Combobox.Parent:=form1;
Grid.Objects[ACol,ARow]:=Combobox;
Grid.Objects[ACol,ARow].AfterConstruction;
R:= Grid.CellRect(ACol,ARow);
if (Grid.Objects[ACol,ARow] is TControl) then
   with TControl(Grid.Objects[ACol,ARow]) do
      if R.Right = R.Left then
         Visible:=false
         else
         begin
         InflateRect(R, -1, -1);
         OffsetRect(R, Grid.Left+1, Grid.Top+1);
         BoundsRect:=R;
         Visible:=true;
         end;
end;


Применение:
Код

procedure TForm1.BitBtn1Click(Sender: TObject);
 begin
ComboboxInStringGrid(StringGrid1,1,1);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
ComboboxInStringGrid(StringGrid1,2,2);
end;


Добавлено @ 01:00 
если хочешь сразу заполнять Combobox, то можно сделать так:
Код

// процедура вставки ComboBox    
// Grid - StringGrid в который вставляется ComboBox    
// ACol, ARow - адрес ячейки в которую вставить ComboBox    
// List - передаваемый в Комбобокс список
 procedure ComboboxInStringGrid(var Grid:TStringGrid; ACol, ARow:Integer; List:TStringList);    
 var    
  R:TRect;    
  Combobox:TCombobox;    
begin    
Combobox:=Tcombobox.Create(nil);    
Combobox.Parent:=form1;
if List.Count>0 then
   Combobox.Items.AddStrings(List);    
Grid.Objects[ACol,ARow]:=Combobox;    
Grid.Objects[ACol,ARow].AfterConstruction;    
R:= Grid.CellRect(ACol,ARow);    
if (Grid.Objects[ACol,ARow] is TControl) then    
   with TControl(Grid.Objects[ACol,ARow]) do    
      if R.Right = R.Left then    
         Visible:=false    
         else    
         begin    
         InflateRect(R, -1, -1);    
         OffsetRect(R, Grid.Left+1, Grid.Top+1);    
         BoundsRect:=R;    
         Visible:=true;    
         end;    
end;


использование:
Код

procedure TForm1.BitBtn1Click(Sender: TObject);
var L:TStringList; 
begin
L:=TStringList.Create;
L.Clear;
{тута мы заполняем список L}
ComboboxInStringGrid(StringGrid1,1,1,L);
end;

но если передашь не созданный список L:=TStringList.Create, то будет вылетать ошибка, из-за чего комбобокс упадёт на форму, а не в Грид

Автор: WhiteSNAKE 5.8.2006, 16:00
Ну, блин! Офигительное тебе,  Albinos_x, спасибо! Будешь в Солигорске (Беларусь) - пивка обязательно попьем  smile

Добавлено @ 16:11 
 smile 

Автор: Albinos_x 5.8.2006, 22:58
Был рад помочь smile 

Заглядывайте ещё...

Автор: Albinos_x 17.8.2006, 19:38
1. WhiteSNAKE,  в следующий раз лучше создавай отдельную тему для этого, или т.к. вопрос фактически не решён пиши в той же теме... а не пиши в личку... я могу на форуме длительное время не появляться, поэтому ответа можешь ждать долго...

2.
Цитата(WhiteSNAKE @  8.8.2006,  13:23)
Подскажи пожалуйста, как из этих ComboBox'ов достать их значения, ведь они просто вставляются по координатам ячейки и принимают их размеры, причём они не являются ячейками.


обращаться можно по координатам, т.к. у StringGrid есть свойство Objects, куда мы и вставляем ComboBox...

3.
Цитата(WhiteSNAKE @  8.8.2006,  13:23)
В моей программе таблица 10 на 10 и видно только первых 7,5 ячеек, она делает в строке 6 и один неполный ComboBox  вместо нужных мне 10. Конечно можно уменьшить ширину столбца таблицы, но тогда как сделать перенос по словам как в TLabel?


она делает все ComboBox-ы, но прорисовываем мы их в ручную, поэтому при прокрутке необходимо перерисовывать их заново (перерисовывать, а не создавать заново!!!)...

4. Пример всего сказанного выше:
Код
...
type
  TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    procedure BitBtn1Click(Sender: TObject);
    procedure StringGrid1TopLeftChanged(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);

....

procedure ComboboxInStringGrid(var Grid:TStringGrid; ACol, ARow:Integer);
 var
  R:TRect;
  Combobox:TCombobox;
begin
Combobox:=Tcombobox.Create(nil);
Combobox.Parent:=form1;
Grid.Objects[ACol,ARow]:=Combobox;
Grid.Objects[ACol,ARow].AfterConstruction;
R:= Grid.CellRect(ACol,ARow);
if (Grid.Objects[ACol,ARow] is TControl) then
   with TControl(Grid.Objects[ACol,ARow]) do
      if R.Right = R.Left then
         Visible:=false
         else
         begin
     //    if (r.Right=r.Left+Grid.ColWidths[ACol]) and
     //        (r.Bottom=r.Top+Grid.RowHeights[ARow]) then
            begin
            InflateRect(R, -1, -1);
            OffsetRect(R, Grid.Left+1, Grid.Top+1);
            BoundsRect:=R;
            Visible:=true;
            end
      //      else
       //     Visible:=false;
         end;
end;

procedure DrawComboStringGrid(var Grid:TStringGrid);
 var
  R:TRect;
  ACol, ARow:Integer;
  Col, Row:Integer;
  i,j:Integer;
begin
Col:=Grid.VisibleColCount;
Row:=Grid.VisibleRowCount;
ACol:=Grid.LeftCol;
ARow:=Grid.TopRow;
for i:=Grid.FixedCols to (ACol+Col) do
   for j:=Grid.FixedRows to (ARow+Row) do
      begin
      R:= Grid.CellRect(i,j);
      if (Grid.Objects[i,j] is TControl) then
         with TControl(Grid.Objects[i,j]) do
            if R.Right = R.Left then
               Visible:=false
               else
               begin
        //       if (r.Right=r.Left+Grid.ColWidths[ACol]) and
        //           (r.Bottom=r.Top+Grid.RowHeights[ARow]) then
                 begin
                 InflateRect(R, -1, -1);
                 OffsetRect(R, Grid.Left+1, Grid.Top+1);
                 BoundsRect:=R;
                 Visible:=true;
                 end
        //         else
        //         Visible:=false;
               end;
        end;
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
var i,j:integer;
begin
for i:=1 to StringGrid1.RowCount-1 do
   for j:=1 to StringGrid1.ColCount-1 do
      begin
      ComboboxInStringGrid(StringGrid1,j,i);
      end;
end;

procedure TForm1.StringGrid1TopLeftChanged(Sender: TObject);
begin
DrawComboStringGrid(StringGrid1);
end;

procedure TForm1.BitBtn2Click(Sender: TObject);
begin
(StringGrid1.Objects[1,1] as TComboBox).Items.Add('Hello World!!!')
end;
...


код снесённый в примечание, должен обеспечивать отказ в прорисовке, если ячейку видно не полностью...

Автор: WhiteSNAKE 26.8.2006, 15:03
Спасибо тебе большое!!! Долго не заходил потому, что мопед грёбнулся после грозы (сетевой фильтр гно...) пришлось через свой телефон в сетку залазить.

Наверное достал уже, но всё таки как достать эти значения??? Мне нужно всё это передать в двумерный массив для последующих расчетов. Смотрю свойство Objects но там нельзя выбрать ItemIndex и потом ведь т.к. это процедура, то все данные теряются, получается что после того как все данные введены, надо заново запускать эту же процедуру и из неё уже передавать значения в сам StringGrid или в матрицу. Я что-то пытался, но нифига не получается, да и почитать негде... В DRKB тоже ничего нет.  Где найти чего-нибудь путного??? 

Автор: Albinos_x 27.8.2006, 11:33
Цитата(WhiteSNAKE @  26.8.2006,  15:03 Найти цитируемый пост)
Наверное достал уже, но всё таки как достать эти значения???

я же приводил пример, как обращаться к объекту:
Цитата(Albinos_x @  17.8.2006,  19:38 Найти цитируемый пост)
(StringGrid1.Objects[1,1] as TComboBox).Items.Add('Hello World!!!')


Цитата(WhiteSNAKE @  26.8.2006,  15:03 Найти цитируемый пост)
Смотрю свойство Objects но там нельзя выбрать ItemIndex

??? почему нельзя??? всё можно...

Цитата(WhiteSNAKE @  26.8.2006,  15:03 Найти цитируемый пост)
и потом ведь т.к. это процедура, то все данные теряются, получается что после того как все данные введены, надо заново запускать эту же процедуру и из неё уже передавать значения в сам StringGrid или в матрицу

почему теряются??? ничего не теряется... всё хранится в StringGrid1.Objects...

вот пример ещё один, более совершенный:
Код

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids;


type
  TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    Button1: TButton;
    Button2: TButton;
    StringGrid2: TStringGrid;
    Button3: TButton;
    procedure StringGrid1TopLeftChanged(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure PresEnterCombo(Sender:TObject; var key:Char);
  private
    { Private declarations }


  public
    { Public declarations }

  end;




  procedure ComboboxInStringGrid(var Grid:TStringGrid; ACol, ARow:Integer);
  procedure DrawComboStringGrid(var Grid:TStringGrid);
  



var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure ComboboxInStringGrid(var Grid:TStringGrid; ACol, ARow:Integer);
 var
  R:TRect;
  Combobox:TCombobox;
begin
Combobox:=Tcombobox.Create(nil);    
Combobox.Parent:=form1;
Combobox.OnKeyPress:=Form1.PresEnterCombo;
Grid.Objects[ACol,ARow]:=Combobox;
Grid.Objects[ACol,ARow].AfterConstruction;
R:= Grid.CellRect(ACol,ARow);    
if (Grid.Objects[ACol,ARow] is TControl) then    
   with TControl(Grid.Objects[ACol,ARow]) do
      if R.Right = R.Left then    
         Visible:=false    
         else    
         begin    
     //    if (r.Right=r.Left+Grid.ColWidths[ACol]) and    
     //        (r.Bottom=r.Top+Grid.RowHeights[ARow]) then    
            begin    
            InflateRect(R, -1, -1);    
            OffsetRect(R, Grid.Left+1, Grid.Top+1);    
            BoundsRect:=R;    
            Visible:=true;    
            end    
      //      else    
       //     Visible:=false;    
         end;        // Combobox.SelStart:=0;
end;


procedure DrawComboStringGrid(var Grid:TStringGrid);
 var    
  R:TRect;    
  ACol, ARow:Integer;    
  Col, Row:Integer;    
  i,j:Integer;    
begin    
Col:=Grid.VisibleColCount;    
Row:=Grid.VisibleRowCount;    
ACol:=Grid.LeftCol;    
ARow:=Grid.TopRow;    
for i:=Grid.FixedCols to (ACol+Col) do    
   for j:=Grid.FixedRows to (ARow+Row) do    
      begin    
      R:= Grid.CellRect(i,j);    
      if (Grid.Objects[i,j] is TControl) then    
         with TControl(Grid.Objects[i,j]) do
            if R.Right = R.Left then    
               Visible:=false    
               else    
               begin    
        //       if (r.Right=r.Left+Grid.ColWidths[ACol]) and    
        //           (r.Bottom=r.Top+Grid.RowHeights[ARow]) then    
                 begin    
                 InflateRect(R, -1, -1);    
                 OffsetRect(R, Grid.Left+1, Grid.Top+1);
                 BoundsRect:=R;
                 (Grid.Objects[i,j] as TComboBox).SelStart:=0;
                 Visible:=true;
                 end
        //         else
        //         Visible:=false;    
               end;
        end;
end;


procedure TForm1.PresEnterCombo(Sender:TObject; var key:Char);
begin
if key=#13 then
   begin
   if (Sender as TComboBox).Text<>'' then
      begin
      (Sender as TComboBox).Items.Add((Sender as TComboBox).Text);
      (Sender as TComboBox).Text:='';
      end;
   end;
end;

procedure TForm1.StringGrid1TopLeftChanged(Sender: TObject);
begin
DrawComboStringGrid(StringGrid1);
end;

procedure TForm1.Button1Click(Sender: TObject);
var i,j:integer;    
begin    
for i:=1 to StringGrid1.RowCount-1 do    
   for j:=1 to StringGrid1.ColCount-1 do    
      begin    
      ComboboxInStringGrid(StringGrid1,j,i);
      end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var i,j:integer;
begin
for i:=1 to (StringGrid1.ColCount-1) do
   for j:=1 to (StringGrid1.RowCount-1) do
      begin
      if (StringGrid1.Objects[i,j] as TComboBox)<>nil then
         begin
         (StringGrid1.Objects[i,j] as TComboBox).Items.Add(inttostr(i)+'/'+inttostr(j));
         (StringGrid1.Objects[i,j] as TComboBox).ItemIndex:=0;
         end
         else
         StringGrid1.Cells[i,j]:=inttostr(i)+'/'+inttostr(j);
      end;
end;

procedure TForm1.FormDestroy(Sender: TObject);
var i,j:integer;
begin
for i:=1 to (StringGrid1.ColCount-1) do
   for j:=1 to (StringGrid1.RowCount-1) do
      begin
      if (StringGrid1.Objects[i,j] as TComboBox)<>nil then
         begin
         (StringGrid1.Objects[i,j]  as TComboBox).Free;
          StringGrid1.Objects[i,j]:=nil;
         end;
      end;
end;

procedure TForm1.Button3Click(Sender: TObject);
var i,j:integer;
begin
StringGrid2.RowCount:=StringGrid1.RowCount;
StringGrid2.ColCount:=StringGrid1.ColCount;
for i:=1 to (StringGrid1.ColCount-1) do
   for j:=1 to (StringGrid1.RowCount-1) do
      begin
      if (StringGrid1.Objects[i,j] as TComboBox)<>nil then
         StringGrid2.Cells[i,j]:=(StringGrid1.Objects[i,j] as TComboBox).Text
         else
         StringGrid2.Cells[i,j]:=StringGrid1.Cells[i,j];
      end;
end;

end.

Button1Click - создание комбобоксов в ячейках
Button2Click - добавление во все комбобоксы значения и установки ItemIndex:=0
Button3Click - перенос выбранных или набранных значений из ячеек-комбобоксов во второй StringGrid
FormDestroy - освобождение памяти
StringGrid1TopLeftChanged - событие прокрутки StringGrid1
PresEnterCombo - обработка события нажатия Enter, при этом набранное значение добавляется в список Комбобокса
DrawComboStringGrid - перерисовка Комбобоксов в StringGrid
ComboboxInStringGrid - вставка комбобокса в ячейку StringGrid-а

Добавлено @ 11:45 
вот пример тебе ещё прикрепляю

Автор: Albinos_x 27.8.2006, 12:43
вот сделал для тебя набор функций для работы с этими комбобоксами:
Код
...
  {событие обработки нажатие на Enter}
  procedure PresEnterCombo(Sender:TObject; var key:Char);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

  {вставка Combobox в ячейку StringGrid}
  procedure ComboboxInStringGrid(var Grid:TStringGrid; ACol, ARow:Integer);
  {перерисовка Combobox в ячейках StringGrid}
  procedure DrawComboStringGrid(var Grid:TStringGrid);
  {чтение свойства Text Combobox}
  function ReadTextStringGridAsCombo(Grid:TStringGrid;  ACol, ARow:Integer):String;
  {добавление в список строки}
  procedure AddTextStringGridAsCombo(var Grid:TStringGrid;  ACol, ARow:Integer; Text:String);
  {чтение всех значений списка}
  function ReadStringListStringGridAsCombo(Grid:TStringGrid;  ACol, ARow:Integer):TStringList;
  {Установка свойства ItemIndex вставленного Combobox}
  procedure SetItemIndexStringGridAsCombo(var Grid:TStringGrid;  ACol, ARow:Integer; ItemIndex:Integer);
  {Удаление одной строки из списка Combobox}
  procedure DeleteItemStringGridAsCombo(var Grid:TStringGrid;  ACol, ARow:Integer; ItemIndex:Integer);
  {Очистка списка Combobox}
  procedure ClearStringGridAsCombo(var Grid:TStringGrid;  ACol, ARow:Integer);
  {Удаление Combobox из ячейки StringGrid}
  Procedure FreeStringGridAsCombo(var Grid:TStringGrid;  ACol, ARow:Integer);

...

procedure ComboboxInStringGrid(var Grid:TStringGrid; ACol, ARow:Integer);
 var
  R:TRect;
  Combobox:TCombobox;
begin
Combobox:=Tcombobox.Create(nil);
Combobox.Parent:=form1;
// здесь событие обработки добавляем
Combobox.OnKeyPress:=Form1.PresEnterCombo;
Grid.Objects[ACol,ARow]:=Combobox;
Grid.Objects[ACol,ARow].AfterConstruction;
R:= Grid.CellRect(ACol,ARow);
if (Grid.Objects[ACol,ARow] is TControl) then
   with TControl(Grid.Objects[ACol,ARow]) do
      if R.Right = R.Left then
         Visible:=false
         else
         begin    
     //    if (r.Right=r.Left+Grid.ColWidths[ACol]) and
     //        (r.Bottom=r.Top+Grid.RowHeights[ARow]) then
            begin
            InflateRect(R, -1, -1);    
            OffsetRect(R, Grid.Left+1, Grid.Top+1);
            BoundsRect:=R;
            Visible:=true;
            end    
      //      else
       //     Visible:=false;
         end;        // Combobox.SelStart:=0;
end;


procedure DrawComboStringGrid(var Grid:TStringGrid);
 var
  R:TRect;
  ACol, ARow:Integer;    
  Col, Row:Integer;
  i,j:Integer;    
begin
Col:=Grid.VisibleColCount;
Row:=Grid.VisibleRowCount;    
ACol:=Grid.LeftCol;
ARow:=Grid.TopRow;
for i:=Grid.FixedCols to (ACol+Col) do    
   for j:=Grid.FixedRows to (ARow+Row) do    
      begin
      R:= Grid.CellRect(i,j);    
      if (Grid.Objects[i,j] is TControl) then    
         with TControl(Grid.Objects[i,j]) do
            if R.Right = R.Left then
               Visible:=false
               else
               begin    
        //       if (r.Right=r.Left+Grid.ColWidths[ACol]) and    
        //           (r.Bottom=r.Top+Grid.RowHeights[ARow]) then
                 begin    
                 InflateRect(R, -1, -1);    
                 OffsetRect(R, Grid.Left+1, Grid.Top+1);
                 BoundsRect:=R;
                 (Grid.Objects[i,j] as TComboBox).SelStart:=0;
                 Visible:=true;
                 end
        //         else
        //         Visible:=false;
               end;
        end;
end;


procedure TForm1.PresEnterCombo(Sender:TObject; var key:Char);
begin
if key=#13 then
   begin
   if (Sender as TComboBox).Text<>'' then
      begin
      (Sender as TComboBox).Items.Add((Sender as TComboBox).Text);
      (Sender as TComboBox).Text:='';
      end;
   end;
end;


function ReadTextStringGridAsCombo(Grid:TStringGrid;  ACol, ARow:Integer):String;
begin
if (Grid.Objects[ACol, ARow] as TComboBox)<>nil then
   result:=(Grid.Objects[ACol, ARow] as TComboBox).Text
   else
   result:='';
end;

procedure AddTextStringGridAsCombo(var Grid:TStringGrid;  ACol, ARow:Integer; Text:String);
begin
if Text<>'' then
   if (Grid.Objects[ACol, ARow] as TComboBox)<>nil then
      (Grid.Objects[ACol, ARow] as TComboBox).Items.Add(Text);
end;

function ReadStringListStringGridAsCombo(Grid:TStringGrid;  ACol, ARow:Integer):TStringList;
begin
Result:=TStringList.Create;
Result.Clear;
if (Grid.Objects[ACol, ARow] as TComboBox)<>nil then
   result.AddStrings((Grid.Objects[ACol, ARow] as TComboBox).Items);
end;

procedure AddStringListStringGridAsCombo(var Grid:TStringGrid;  ACol, ARow:Integer; List:TStringList);
begin
if List<>nil then
   if (Grid.Objects[ACol, ARow] as TComboBox)<>nil then
      (Grid.Objects[ACol, ARow] as TComboBox).Items.AddStrings(List);
end;

procedure SetItemIndexStringGridAsCombo(var Grid:TStringGrid;  ACol, ARow:Integer; ItemIndex:Integer);
begin
if ItemIndex>=0 then
   if (Grid.Objects[ACol, ARow] as TComboBox)<>nil then
      if ItemIndex<=((Grid.Objects[ACol, ARow] as TComboBox).Items.Count-1) then
         (Grid.Objects[ACol, ARow] as TComboBox).ItemIndex:=ItemIndex;
end;

procedure DeleteItemStringGridAsCombo(var Grid:TStringGrid;  ACol, ARow:Integer; ItemIndex:Integer);
begin
if ItemIndex>=0 then
   if (Grid.Objects[ACol, ARow] as TComboBox)<>nil then
      if ItemIndex<=((Grid.Objects[ACol, ARow] as TComboBox).Items.Count-1) then
         (Grid.Objects[ACol, ARow] as TComboBox).Items.Delete(ItemIndex);
end;

procedure ClearStringGridAsCombo(var Grid:TStringGrid;  ACol, ARow:Integer);
begin
if (Grid.Objects[ACol, ARow] as TComboBox)<>nil then
   (Grid.Objects[ACol, ARow] as TComboBox).Clear;
end;

Procedure FreeStringGridAsCombo(var Grid:TStringGrid;  ACol, ARow:Integer);
begin
if (Grid.Objects[ACol, ARow] as TComboBox)<>nil then
   begin
   (Grid.Objects[ACol, ARow]  as TComboBox).Free;
   Grid.Objects[ACol, ARow]:=nil;
   end;
end;
...

Автор: WhiteSNAKE 31.8.2006, 23:45
Спасибо большое!!! smile Разобрался smile  всё ТИП-ТОП!!!

Автор: Albinos_x 1.9.2006, 04:47
Был рад помоч. Заглядывай ещё smile 

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)