DBGrid a pionowy scrollbar raz jeszcze

0

Witam wszystkich.

Znalazłem takie rozwiązanie aby usunąć pionowy scrollbar w DBGridzie:

// 2840:Removing the vertical scrollbar from a TDBGrid

// In order to remove the vertical scrollbar from a TDBGrid component,
// you must override its Paint method.  Inside the Paint method you
// must call the SetScrollRange API procedure to set the min and max
// scroll values to zero (this disables the scrollbar), and then call
// the inherited Paint.


type
  TNoVertScrollDBGrid = class(TDBGrid)
  protected
    procedure Paint; override;
  end;


implementation

procedure TNoVertScrollDBGrid.Paint;
begin
  SetScrollRange(Self.Handle, SB_VERT, 0, 0, False);
  inherited Paint;
end;

i wszystko jest pięknie, pionowy scrollbar jest usunięty, ale w momencie przewijania rekordów scrollbar pokazuje się na ułamek sekundy i znika, jest to bardzo nieciekawy efekt :(

Czy ktoś wie jak się tego pozbyć tego efektu?

0

Masz jakąś ukryta kolumnę gdzieś na końcu tabeli?

0
(*

Q:
I want to hide the vertical scrollbar on a dbgrid when the record count
exceed a number. How can I do that?

A:
Make a descendent of the TDBGrid class. Add a handler for the
WM_NCCALCSIZE message.

*)

type
  TNoScrollDBGrid = class(TDBGrid)
  private
    procedure WMNCCalcSize(var Msg: TMessage);
      message WM_NCCALCSIZE;
  end;

procedure TNoScrollDBGrid.WMNCCalcSize(var Msg: TMessage);
const
  Scrollstyles = WS_VSCROLL or WS_HSCROLL;
var
  Style: Integer;
begin
  Style := GetWindowLong(Handle, GWL_STYLE);
  if (Style and Scrollstyles) <> 0 then
    SetWindowLong(Handle, GWL_STYLE, Style and not Scrollstyles);
  inherited;
end;

//This removes both scrollbars. If you want to remove only the vertical one
//change the scrollstyles constant accordingly.
//w konstruktorze
ShowScrollBar(DBGrid1.Handle, SB_VERT, False);

czy też hardkorowo :D

The low tech solution is to place a panel over it <g> (but it is
surprisingly effective!)

0

Do RedbaK:

Ukryta kolumna jest, ale nawet po odkryciu kolumny i rozciągnięciu Grida efekt był ten sam.

Ale MisiekD rozwiązał problem [browar]
Ten hardkor jest cool :d

THK for all.

0

Wystarczy ukrytą kolumnę przenieść bliżej (o 1 lub 2 pozycje) do lewej strony tabeli, gdzieś pomiędzy kolumny widoczne i to wszystko. U mnie to zawsze działa, gdy pojawi mi się zbędny poziomy lub pionowy pasek.

0

A jednak nie wszystko jest OK. :(

Teraz przestało działać OnDrawDataCell :(

0
Młody napisał(a)

A jednak nie wszystko jest OK. :(

Teraz przestało działać OnDrawDataCell :(

oczywiście (oczy wiście) helpa cztasz i się stosujesz ...

delphi7 help napisał(a)

Description

Do not write an OnDrawDataCell event handler. OnDrawDataCell is obsolete and included for backward compatibility. Instead, write an OnDrawColumnCell event handler.

0

Sorki.

Już sam nie raz to czytałem, [glowa] ... ah.. ta pamięć [glowa]

Dziękuje za rozwiązanie problemu. Pozdrowionka :)

0

sory wpinam się w cudzy post ale po co zakładać kolejny również chce usunać scrollbar nie potrzeba mi tego, pytanie do miśkaD bo do jego odpowiedzi nawiazuje a jesli go nie ma to prosze o pomoc kogokolwiek

(*

Q:
I want to hide the vertical scrollbar on a dbgrid when the record count
exceed a number. How can I do that?

A:
Make a descendent of the TDBGrid class. Add a handler for the
WM_NCCALCSIZE message.

*)

type
  TNoScrollDBGrid = class(TDBGrid)
  private
    procedure WMNCCalcSize(var Msg: TMessage);
      message WM_NCCALCSIZE;
  end;

procedure TNoScrollDBGrid.WMNCCalcSize(var Msg: TMessage);
const
  Scrollstyles = WS_VSCROLL or WS_HSCROLL;
var
  Style: Integer;
begin
  Style := GetWindowLong(Handle, GWL_STYLE);
  if (Style and Scrollstyles) <> 0 then
    SetWindowLong(Handle, GWL_STYLE, Style and not Scrollstyles);
  inherited;
end;

//This removes both scrollbars. If you want to remove only the vertical one
//change the scrollstyles constant accordingly. 
 



//w konstruktorze
ShowScrollBar(DBGrid1.Handle, SB_VERT, False);

gdzie dokładnie umieścić to

//w konstruktorze
ShowScrollBar(DBGrid1.Handle, SB_VERT, False);

dzięki
pozdrawiam

1 użytkowników online, w tym zalogowanych: 0, gości: 1