Dbgrid com campo checkbox .. HELP URGENTE
preciso fazer um DBgrid que o campo que será permitido acesso deve ser um checkbox .... como fazer ???
Carlos Jatai
Curtidas 0
Respostas
Aroldo Zanela
27/07/2003
Colega,
Uma idéia:
Outra
Mais fácil:
Uma idéia:
1) add to the DataSet Calculated Field : char[1];
2) Show it on the grid instead of Boolean with WinDing font;
3) Use OnCellClick event to toggle boolean field.
4) Set DataSet.OnCalcFields event to assign calculated field to a symbol
that is draw as an empty|marked checkbox in WinDing font, according to value
of Boolean field.
Outra
Next code will draw a checkbox in specified rect with specified state: procedure DrawCheckBox(R: TRect; AState: TCheckBoxState; al: TAlignment); var DrawState: Integer; DrawRect: TRect; begin case AState of cbChecked: DrawState := DFCS_BUTTONCHECK or DFCS_CHECKED; cbUnchecked: DrawState := DFCS_BUTTONCHECK; else // cbGrayed DrawState := DFCS_BUTTON3STATE or DFCS_CHECKED; end; case al of taRightJustify: begin DrawRect.Left := R.Right - FCheckWidth; DrawRect.Right := R.Right; end; taCenter: begin DrawRect.Left := R.Left + (R.Right - R.Left - FCheckWidth) div 2; DrawRect.Right := DrawRect.Left + FCheckWidth; end; else // taLeftJustify DrawRect.Left := R.Left; DrawRect.Right := DrawRect.Left + FCheckWidth; end; DrawRect.Top := R.Top + (R.Bottom - R.Top - FCheckWidth) div 2; DrawRect.Bottom := DrawRect.Top + FCheckHeight; DrawFrameControl(Canvas.Handle, DrawRect, DFC_BUTTON, DrawState); end;
Mais fácil:
So just call this procedure from OnDrawCell event. It work for me in
freeware TSMDBGrid (see my site)
--
With best regards, Mike Shkolnik
EMail: mshkolnik@scalabium.com
http://www.scalabium.com
GOSTEI 0