Přidat otázku mezi oblíbenéZasílat nové odpovědi e-mailem Delphi - DBGrid - vyfarbovanie buniek a zadanie názvov stĺpcov sa bije

1. Toto nesúvisí s názvom vlákna, viem to obísť dostačujúcim riešením:
Pri vyfarbovaní, ak nemá DBGrid focus, tak správne má byť riadok len označený zobáčikom a nemá byť modro vysvietený, lenže ak pri vyfarbovaní testujem, či má riadok focus, tak nech to robím akokoľvek,

  if (gdFocused in State) and (gdSelected in State) then
    begin
      (Sender as TDBGrid).DefaultDrawDataCell(Rect, Field, State);
      exit;
  if (gdFocused in State) and (gdSelected in State) then
    begin
      exit;
  if (gdFocused in State) then
    begin
      (Sender as TDBGrid).DefaultDrawDataCell(Rect, Field, State);
      exit;
  if (gdFocused in State) then
    begin
      exit;

stále to rovnako nefunguje:
[http://img402.imageshack.us/img402/5715/schrnka01tx 1.gif]
Riešenie spočíva v tom, že netestujem focus, iba selektovanie, ale potom je modrý pás aj vtedy, ak nemá DBGrid focus. V DBGrid mám nastavené RowSelect na true, takže v tom problém nespočíva.

2. No a toto súvisí s názvom vlákna:
Pomocou OnDrawDataCell som si vytvoril metódu na farbenie buniek. Po zadaní hodnôt DBGrid.Columns[1..n] v Object Inspectore mi prestalo vyfarbovať bunky. Čo s tým teraz? Vyplnené Columns je nutnosťou kvôli správnemu zobrazeniu diakritiky v názvoch stĺpcov (Čas, Pracovníci, Názov, atď.).

Jsou zobrazeny jen nové odpovědi. Zobrazit všechny
Předmět Autor Datum
// Enter the following code in the TDBGrid's OnDrawDataCell event: Procedure TForm1.DBGrid1DrawData… poslední
pme 28.04.2007 10:06
pme

// Enter the following code in the TDBGrid's OnDrawDataCell event:

Procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
begin
  If gdFocused in State then
    with (Sender as TDBGrid).Canvas do
    begin
      Brush.Color := clRed;
      FillRect(Rect);
      TextOut(Rect.Left, Rect.Top, Field.AsString);
    end;
end;

// Set the Default drawing to true. With this, it only has to draw the
// highlighted cell. If you set DefaultDrawing to false, you must draw all
// the cells yourself with the canvas properties.

Zpět do poradny Odpovědět na původní otázku Nahoru