Embedding Controls in IWGrid Cells

Last Updated: 6/2/2009



Sections above here:
Home  »  Class Reference  »  TIWGrid

Sections below here:

    Topics in this section:
    Embedding Controls in IWGrid Cells
    How to Add Rows and Columns to a IWGrid

    Search Documentation:

    In order to embed some controls to your IWGrid, you need to create the controls and then assign these controls to the property Control of the IWGrid Cell you want.

    The OnRenderCell event is triggered for every cell of the IWGrid and is the best place to add Controls to the Grid. The ACell parameter is the Cell being rendered. ARow and AColumn indicates the number of the row and column of the cell. The first row and column are always 0. The last row of your IWGrid is IWGrid.RowCount -1 and the last column is IWGrid.ColumnCount - 1.

    procedure TIWForm3.IWGrid1RenderCell(ACell: TIWGridCell; const ARow, AColumn: Integer);
    begin
    with ACell do
    begin
    // try to find if the control was already created
    Control :=
    TIWComboBox(FindComponent('IWComboBox' + IntToStr(ARow)));
    if Control = nil then
    begin
    Control := TIWComboBox.Create(Self); // the control will be destroyed by the IWForm
    TIWComboBox(Control).Name := 'IWComboBox' + IntToStr(ARow);
    TIWComboBox(Control).Tag := ARow; // for easy identification
    TIWComboBox(Control).OnClick := IWComboBoxClick;
    PopulateComboBox(TIWComboBox(Control));
    end;
    end;
    end;

    procedure TIWForm3.IWComboBoxClick(Sender: TObject);
    begin
    if Sender is TIWComboBox then
    with Sender as TIWComboBox do begin
    case Tag of
    0: DoThis;
    1: DoThat;
    2: MoreThingsToDo;
    else
    EverythinElse;
    end;
    end;
    end;



    (C) 2002-2009 - Atozed Software Ltd.