--- In [EMAIL PROTECTED], arief firdaus <[EMAIL PROTECTED]> wrote:
> hai man treman saya minta tolong lagi nich!
> gimana ya caranya untuk create control di string grid,
> misal waktu saya activ di cell tertentu otomatis akan
> create TextBox persis di cell yang bersangkutan dan
> satu lagi gimana biar cell tersebut baik background
> dan text nya berwarna ?
>
> ditunggu ya jawabannya
> makasih...
>
> TIA
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail Address AutoComplete - You start. We finish.
> http://promotions.yahoo.com/new_mail
sorry panjang
-- Custom InPlace Editor in StringGrid - by Borland Developer
Support Staff
Question and Answer Database
FAQ2434D.txt Custom InPlace Editor in StringGrid
Category :VCL
Platform :All
Product :Delphi 3.x
Question:
How can I popup my own inplace editor (such as a combobox)
in a string grid cell?
Answer:
The following example demonstrates popping up a Combobox
as an inplace editor to a Stringrid component.
Example:
procedure TForm1.FormCreate(Sender: TObject);
begin
{The combobox height is not settable, so we will}
{instead size the grid to fit the combobox!}
StringGrid1.DefaultRowHeight := ComboBox1.Height;
{Hide the combobox}
ComboBox1.Visible := False;
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
{Get the ComboBox selection and place in the grid}
StringGrid1.Cells[StringGrid1.Col,
StringGrid1.Row] :=
ComboBox1.Items[ComboBox1.ItemIndex];
ComboBox1.Visible := False;
StringGrid1.SetFocus;
end;
procedure TForm1.ComboBox1Exit(Sender: TObject);
begin
{Get the ComboBox selection and place in the grid}
StringGrid1.Cells[StringGrid1.Col,
StringGrid1.Row] :=
ComboBox1.Items[ComboBox1.ItemIndex];
ComboBox1.Visible := False;
StringGrid1.SetFocus;
end;
procedure TForm1.StringGrid1SelectCell(Sender: TObject; Col,
Row: Integer; var CanSelect: Boolean);
var
R: TRect;
begin
if ((Col = 3) AND
(Row <> 0)) then begin
{Size and position the combo box to fit the cell}
R := StringGrid1.CellRect(Col, Row);
R.Left := R.Left + StringGrid1.Left;
R.Right := R.Right + StringGrid1.Left;
R.Top := R.Top + StringGrid1.Top;
R.Bottom := R.Bottom + StringGrid1.Top;
ComboBox1.Left := R.Left + 1;
ComboBox1.Top := R.Top + 1;
ComboBox1.Width := (R.Right + 1) - R.Left;
ComboBox1.Height := (R.Bottom + 1) - R.Top;
{Show the combobox}
ComboBox1.Visible := True;
ComboBox1.SetFocus;
end;
CanSelect := True;
end;
7/16/98 4:31:28 PM
-- untuk ganti warna cell di stringgrid (lupa source web dari mana)
procedure TForm1.StringGridDrawCell(Sender: TObject; ACol, ARow:
Integer;
Rect: TRect; State: TGridDrawState);
//var
// Y: Integer;
begin
with (Sender as TStringGrid) do
begin
// Don't change color for first Column, first row
if (ACol = 0) or (ARow = 0) then
Canvas.Brush.Color := clBtnFace
else
begin
case ACol of
1..3: Canvas.Font.Color := clBlack;
end;
// Draw the Band
if ARow mod 2 = 0 then
Canvas.Brush.Color := $00E1FFF9
else
Canvas.Brush.Color := $00FFEBDF;
//selection color and stuf
if ARow = Selection.Top then
begin
Canvas.Brush.Color:= clGray;
Canvas.Font.Color:= clWhite;
Canvas.Font.Size:= 11;
end;
Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, cells[acol,
arow]);
Canvas.FrameRect(Rect);
end;
end;
end;
----------
Mudah2an membantu
Berlangganan: [EMAIL PROTECTED]
Stop Berlangganan: [EMAIL PROTECTED]
Keluhan Milis(Unbouncing,spam,dll): [EMAIL PROTECTED]
| Yahoo! Groups Sponsor | |
|
|
Yahoo! Groups Links
- To visit your group on the web, go to:
http://groups.yahoo.com/group/Delphindo/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
