procedure TFenetre_Emploi_de_temps.Grid_emploiDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); var aPos, i: integer; Grid: TStringGrid; s, temp: string; begin Grid := (sender as TStringGrid); if (not Grid.DefaultDrawing) then begin Grid.Canvas.FillRect(Rect); Grid.RowHeights[ARow] := Grid.DefaultRowHeight; temp := Grid.cells[ACol, ARow]; aPos := Pos(sLineBreak, temp); i := 0; if aPos > 0 then begin while aPos > 0 do begin s := Copy(temp, 1, aPos - 1); Grid.Canvas.TextOut(Rect.Left, Rect.Top + 2 - (Grid.Font.Height * i), s); Delete(temp, 1, aPos + Length(sLineBreak) - 1); aPos := Pos(sLineBreak, temp); inc(i); end; end; Grid.Canvas.TextOut(Rect.Left, Rect.Top + 2 - (Grid.Font.Height * i), temp); end; end;
procedure TFenetre_Emploi_de_temps.Grid_emploiDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); begin if (source is TListBox) then Accept:=true else if (source is TsListBox) then Accept:=true; end;
procedure TFenetre_Emploi_de_temps.Grid_emploiDragDrop(Sender, Source: TObject; X, Y: Integer); var CellX,CellY:integer; begin Grid_emploi.MouseToCell(x,y,CellX,CellY); if(Source is TsListBox) then begin Grid_emploi.Cells[CellX,CellY]:=Select_prof; end else if(Source is TListBox) then begin Grid_emploi.Cells[CellX,CellY]:=Select_mat; end; end;
procedure TFenetre_Emploi_de_temps.List_profClick(Sender: TObject); var i:integer; begin for i := 0 to (List_prof.Items.Count-1) do begin if List_prof.Selected[i]=True then begin Select_prof:=List_prof.Items.Strings[i]; end; end; end;
procedure TFenetre_Emploi_de_temps.Grid_emploiDragDrop(Sender, Source: TObject; X, Y: Integer); var CellX,CellY:integer; begin Grid_emploi.MouseToCell(x,y,CellX,CellY); if(Source is TsListBox) then begin Grid_emploi.Cells[CellX,CellY]:= Grid_emploi.Cells[CellX,CellY] + sLineBreak +Select_prof; end else if(Source is TListBox) then begin Grid_emploi.Cells[CellX,CellY]:= Grid_emploi.Cells[CellX,CellY] + sLineBreak +Select_mat; end; end;
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionprocedure TFenetre_Emploi_de_temps.Grid_emploiDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); begin Accept := (source is TlistBox) and (TListBox(Source).SelCount > 0); end; procedure TFenetre_Emploi_de_temps.Grid_emploiDragDrop(Sender, Source: TObject; X, Y: Integer); var CellX, CellY, i: integer; begin Grid_emploi.MouseToCell(x, y, CellX, CellY); if Source is TListBox then {pour chacun des élements du composant source} for i := 0 to TListBox(Source).Items.Count - 1 do {s'il est sélectionné...} if TListBox(Source).Selected[i] then {et si la cellule de destination est vide : on remplace le contenu} if Grid_emploi.Cells[CellX, CellY]= EmptyStr then Grid_emploi.Cells[CellX, CellY] := TListBox(Source).Items[i] else {sinon, on ajoute au contenu existant} Grid_emploi.Cells[CellX, CellY] := Grid_emploi.Cells[CellX, CellY] + sLineBreak + TListBox(Source).Items[i]; end;
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); begin Stringgrid1.Canvas.FillRect(Rect); // effacement de la cellule Drawtext(Stringgrid1.Canvas.Handle, PChar(StringGrid1.Cells[ACol, ARow]), -1, Rect, DT_WORDBREAK); end;
ini.WriteString('contenu','cont1,1',Grid_emploi.Cells[1,1]);