![]() |
![]() |
![]() |
![]() |
![]() |
FTP | ![]() |
![]() |
CCD | ![]() |
![]() |
Buscar | ![]() |
![]() |
Trucos | ![]() |
![]() |
Trabajo | ![]() |
![]() |
Foros | ![]() |
|
Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
![]() |
|
Herramientas | Buscar en Tema | Desplegado |
#1
|
|||
|
|||
Cambiar el estado de un checkbox insertado en un grid.
Que tal amigos un saludo para todos la duda que tengo tiene que ver al agregar un tcheckbox a un grid anexo el codigo con el cual agrego el componente el problema es que no logro cambiarle el estado en tiempo de ejecucion me imagino que el problema esta en que el grid siempre esta repintando el objeto y yo no tengo ni idea de como resolver esto.
Gracias de antemano por la ayuda. Código:
procedure TFormbancos.StringGridmovimientosDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); var sCad:String; i,n,xindex: integer; conciliacheck: TCheckBox; control: tcomponent; begin if ACol=7 then // voy a alinear a la derecha la 3ª columna if ARow>0 then //No quiero alinear la línea de títulos begin conciliacheck := TCheckBox.Create(Self); control:=findcomponent('conciliacheckx' + IntToStr(arow)); if control=nil then begin conciliacheck.Name := 'conciliacheckx' + IntToStr(arow); conciliacheck.Caption :=''; if StringGridmovimientos.Cells[7,ARow]='F' then conciliacheck.Checked := false else conciliacheck.Checked := true; n:=0; for i:=1 to acol do n:=n+StringGridmovimientos.ColWidths[i]+1; conciliacheck.Left:=n; n:=0; for i:=1 to arow do n:=n+StringGridmovimientos.RowHeights[i]+1; conciliacheck.Top:=n; conciliacheck.Width:=13; conciliacheck.Height:=13; conciliacheck.Parent:=StringGridmovimientos; end; end; end;
__________________
Carlos Arevalo MSN Messenger: carlos@arevalo.com.ve |
#2
|
|||
|
|||
no tomen en cuenta los comentarios de las primeras lineas.
Gracias.
__________________
Carlos Arevalo MSN Messenger: carlos@arevalo.com.ve |
#3
|
|||
|
|||
En lugar de un componente checkbox prueba con esto:
Código:
procedure TForm1.StringGridMovimientosDrawCell( Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); const AState: array[Boolean] of Cardinal = (0, DFCS_CHECKED); begin with TStringGrid(Sender) do if (ARow > 0) and (ACol = 7) then begin Canvas.FillRect(Rect); InflateRect(Rect, -2, -2); DrawFrameControl(Canvas.Handle, Rect, DFC_BUTTON, DFCS_BUTTONCHECK or AState[Cells[7, Arow] = 'F']); end; end; Para que cuando el Usuario haga click en el checkbox y se tilde/destilde el mismo programa el Evento "OnMouseUp" del StringGrid con el siguiente código: Código:
procedure TForm1.StringGridMovimientosMouseUp( Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); const AValue: array[Boolean] of String = ('', 'F'); var ACol, ARow: Integer; begin with TStringGrid(Sender) do begin MouseToCell(X, Y, ACol, ARow); if (ARow > 0) and (ACol = 7) then Cells[ACol, ARow] := AValue[not (Cells[ACol, ARow] = 'F')]; end; end; |
#4
|
|||
|
|||
Gracias lo voy a probar y luego comento el resultado
__________________
Carlos Arevalo MSN Messenger: carlos@arevalo.com.ve |
#5
|
|||
|
|||
Exelente viejo muchas gracias funciona de perla.
__________________
Carlos Arevalo MSN Messenger: carlos@arevalo.com.ve |
![]() |
|
|
![]() |
|