Ver Mensaje Individual
  #2  
Antiguo 21-01-2005
ignasi ignasi is offline
Registrado
 
Registrado: feb 2004
Posts: 7
Reputación: 0
ignasi Va por buen camino
Hola Santi,

Te envío dos procedures que me sirvieron para hacer algo parecido a lo que comentas. Se trata de 'pintar' un checkbox en el grid y marcarlo si cumple la condición. Es así:

Código:
 
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; 
  DataCol: Integer; Column: TColumn; State: TGridDrawState); 
var 
  Check: Integer; 
  R: TRect; 
begin 
  if Column.FieldName = 'NombreCampo' then 
  begin 
	DBGrid1.Canvas.FillRect(Rect); 
	Check := 0; 
	if Table1.FindField('NombreCampo').AsBoolean then Check := DFCS_CHECKED; 
	R:=Rect; 
	InflateRect(R,-2,-2); //Disminuye el tamaño del CheckBox 
	DrawFrameControl(DBGrid1.Canvas.Handle,R,DFC_BUTTON, DFCS_BUTTONCHECK or Check); 
  end; 
end; 

procedure TForm1.DBGrid1CellClick(Column: TColumn); 
begin 
  if Column.FieldName = 'NombreCampo' then 
  begin 
	Table1.Edit; 
	Table1.FindField('NombreCampo').AsBoolean:=not Table1.FindField('NombreCampo').AsBoolean; 
  end; 
end;
Espero te sirva,
hasta la próxima.
Responder Con Cita