SetBounds

March 6, 2006 at 6:38 pm | Posted in Code Samples | Leave a comment

by: Ferry Setiawan

Mungkin bisa menjawab beberapa pertanyaan mengenai bagaimana cara kita menampilkan checkbox sesuai jumlah record,Cara ini menggunakan perintah SetBounds.

1. Letakkan DBCheckBox, setting property datasource, datafield, dll, kemudian tentukan valuechecked dan valueunchecked.

procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn;
  State: TGridDrawState);
begin
  if (gdFocused in State) and
    (Column.Field.FieldName = 'Data') then begin
    DBCheckBox1.SetBounds(Rect.Left + DBGrid1.Left + 1,
                          Rect.Top + DBGrid1.Top + 1,
                          Rect.Right - Rect.Left + 1,
                          Rect.Bottom - Rect.Top + 1);
  end;
end;

procedure TForm1.DBGrid1ColEnter(Sender: TObject);
begin
  if DBGrid1.Columns[DBGrid1.SelectedIndex].Field.
    FieldName = 'Data'
  then DBCheckBox1.Visible := True
  else DBCheckBox1.Visible := False;
end;

maka pada saat field data kita select, akan berubah menjadi checkbox.

semoga sedikit membantu.

Leave a Comment »

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.
Entries and comments feeds.

%d bloggers like this: