Le refresh d'une cellule StringGrid
Bonjour à tous,
J'expose ma problématique.
J'ai créer un StringGrid avec en autre l'evenement Draw si dessous :
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| procedure TFormPrincipal.StringGridSemaineDrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
Begin
With Sender As TStringGrid Do With Canvas Do
Begin
if (Arow=1) And (ACol = 0) And (Cote=2) then
Begin
DrawText(Handle, PChar(TitreModifDirecte) , -1, Rect, DT_CENTER or DT_NOPREFIX or DT_VCENTER or DT_SINGLELINE);
end;
end;
end; |
J'ai pas mis toutes la structure de l'evenement cela n'a pas d'interet.
Je créer des composants dynamiquement et je gere sur ces composants plusieur evenements voici celui qui me pause probleme.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| procedure TFormPrincipal.PanelMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
Var
xHeure, xColonne: Integer;
begin
if (Sender is TPanel) then
Begin
TPanel(Sender).Cursor:=CrDefault;
If (X >= TPanel(Sender).Width-3) And (ssCtrl in Shift) then TPanel(Sender).Cursor:=CrHsplit;
if (Cote = 2) then
Begin
if (X > 4) and (X mod 5 = 0) and (X + TPanel(Sender).Left <= MaxXModifDirecte) then
Begin
xColonne:= ((TPanel(Sender).Width + TPanel(Sender).left - (StringGridSemaine.ColWidths[0] + 5))
div StringGridSemaine.DefaultColWidth);
xHeure:= ((StringGridSemaine.DefaultColWidth * NumDateDebutNumItem)
+(TPanel(Sender).Width-(StringGridSemaine.DefaultColWidth * xColonne)))
div 5;
TitreModifDirecte := 'au '+ JModifDirecte.Strings[NumDateFinNumItem] + ' à '+ HModifDirecte.Strings[NumHeureFinNumItem];
StringGridSemaine.Cells[0,1] := TitreModifDirecte;
StringGridSemaine.Refresh;
TPanel(Sender).Width := X;
end;
end;
end;
Shift := [];
end; |
Comme on le voix si je clique Droite+CTRL et que je bouge je me trouve dans cet évenement. Je mets en place un text qui devrait !! mettre à jour la cellule 0,1 mets cela ne le fais qu'une seule fois.
Mon objectif :
Lorsque je bouge mon coposant par cette eveenement je veux donnee a l'utilisateur l'information de son déplacement (xheure, xcolonne).
Lorsque je mets cela dans un Label plutot que sur une cellule du StringGrid cela fonctionnement parfaitement, sauf que ce n'est vraiment pas esthetique.
Alors comment une cellule Stringrid peut changer seloin un mouvement de souris réalisé sur un coposant ?
Merci de vos idées.