2016-11-03 5 views
2

저는 프로젝트에서 Windows 10 테마를 사용하고 있는데, 다음과 같은 사실을 눈치 챘습니다 : 그리드 스크롤바 아래에 그리드의 가장자리에있는 패널, 이 이미지가 있습니다. :패널이 그리드 스크롤바 아래에 표시됩니다.

enter image description here

나는 VCL의 행동, 또는 격자를 변경하거나 동작을 스크롤하지 않았습니다.

PAS 파일 :

unit Unit1; 

interface 

uses 
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, 
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, Vcl.StdCtrls, 
    Datasnap.DBClient, Vcl.Grids, Vcl.DBGrids, Vcl.ExtCtrls; 

type 
    TForm1 = class(TForm) 
    Panel1: TPanel; 
    DbGrid: TDBGrid; 
    Panel2: TPanel; 
    ClientDataSet: TClientDataSet; 
    DataSource1: TDataSource; 
    ButtonAdd: TButton; 
    ShowPanel: TButton; 
    ClientDataSetname: TStringField; 
    ClientDataSetaddress: TStringField; 
    procedure ButtonAddClick(Sender: TObject); 
    procedure FormCreate(Sender: TObject); 
    procedure ShowPanelClick(Sender: TObject); 
    private 
    { Private declarations } 
    public 
    { Public declarations } 
    end; 

var 
    Form1: TForm1; 

implementation 

{$R *.dfm} 

procedure TForm1.ButtonAddClick(Sender: TObject); 
begin 
    ClientDataset.Append; 
    ClientDataSetname.AsString := 'Test name'; 
    ClientDataSetaddress.AsString := 'Test address'; 
    ClientDataset.Insert; 
end; 

procedure TForm1.ShowPanelClick(Sender: TObject); 
begin 
    if Panel2.Visible then 
    Panel2.Visible := False 
    else 
    Panel2.Visible := True; 
end; 

procedure TForm1.FormCreate(Sender: TObject); 
begin 
    ClientDataset.CreateDataSet; 
end; 

end. 

DFM 파일 :

object Form1: TForm1 
    Left = 0 
    Top = 0 
    Caption = 'Form1' 
    ClientHeight = 201 
    ClientWidth = 555 
    Color = clBtnFace 
    Font.Charset = DEFAULT_CHARSET 
    Font.Color = clWindowText 
    Font.Height = -11 
    Font.Name = 'Tahoma' 
    Font.Style = [] 
    OldCreateOrder = False 
    OnCreate = FormCreate 
    PixelsPerInch = 96 
    TextHeight = 13 
    object Panel1: TPanel 
    Left = 460 
    Top = 0 
    Width = 95 
    Height = 201 
    Align = alRight 
    TabOrder = 0 
    object ButtonAdd: TButton 
     Left = 10 
     Top = 16 
     Width = 75 
     Height = 25 
     Caption = 'ButtonAdd' 
     TabOrder = 0 
     OnClick = ButtonAddClick 
    end 
    object ShowPanel: TButton 
     Left = 10 
     Top = 47 
     Width = 75 
     Height = 25 
     Caption = 'ShowPanel' 
     TabOrder = 1 
     OnClick = ShowPanelClick 
    end 
    end 
    object DbGrid: TDBGrid 
    Left = 0 
    Top = 0 
    Width = 460 
    Height = 201 
    Align = alClient 
    DataSource = DataSource1 
    TabOrder = 1 
    TitleFont.Charset = DEFAULT_CHARSET 
    TitleFont.Color = clWindowText 
    TitleFont.Height = -11 
    TitleFont.Name = 'Tahoma' 
    TitleFont.Style = [] 
    Columns = < 
     item 
     Expanded = False 
     FieldName = 'name' 
     Visible = True 
     end 
     item 
     Expanded = False 
     FieldName = 'address' 
     Visible = True 
     end> 
    end 
    object Panel2: TPanel 
    Left = 0 
    Top = 160 
    Width = 185 
    Height = 41 
    Caption = 'panel2' 
    TabOrder = 2 
    Visible = False 
    end 
    object ClientDataSet: TClientDataSet 
    Aggregates = <> 
    Params = <> 
    Left = 216 
    Top = 104 
    object ClientDataSetname: TStringField 
     FieldName = 'name' 
     Size = 50 
    end 
    object ClientDataSetaddress: TStringField 
     FieldName = 'address' 
     Size = 50 
    end 
    end 
    object DataSource1: TDataSource 
    DataSet = ClientDataSet 
    Left = 152 
    Top = 88 
    end 
end 

버그가 ShowPanel에 두 번째 클릭 후 발생합니다.

+0

패널을 넣을 때 이상한 장소. 그럼에도 불구하고 버그입니다. –

+0

델파이에서 "런타임 테마 사용"을 선택하지 않으면 작동합니다. – William

+2

정확히 어떤 그리드를 사용하고 있습니까? 패널이 그리드의 자식 또는 형제입니까? 문제를 시연하는 [Minimal, Complete, Verifiable example] (http://stackoverflow.com/help/mcve)을 제공하면 도움이됩니다. –

답변

0

난 그냥 false로 그리드 seBorder 변경이 문제를 "해결"할 수있는 방법을 발견했습니다, 나는 모든 프로젝트에서 찾을 수 메모장을 ++ 사용 to : ": TDBGrid StyleElements = [seFont, seClient]"¹. seBorder을 false로 변경하면 스크롤바 스타일이 Windows 버전의 스크롤처럼 보이기 때문에이 문제를 해결할 수있는 더 좋은 방법은 아닌 것 같습니다.


¹ 시도 할 때 따옴표를 무시하십시오.

0

DBgrid를 패널의 부모로 정의 할 수 있습니다.

procedure TForm1.FormShow(Sender: TObject); 
begin 
    panel1.Parent := dbgrid1; 
    panel1.align := alBottom; 
end; 
+0

작동하지만 패널 너비를 유지하려고합니다. – William

+0

패널 위치를 정의하기 만하면됩니다. align 속성을 제거하십시오. 학부모회 만 유지하십시오. –

+0

여전히 스크롤 막대 아래에 표시됩니다. – William

-1

실제로 유일한 방법은 DBgrid의 부모와 작업하는 것입니다. 나를 위해 이 예제에서는 잘 작동 : ¹ 및 교체 "을 TDBGrid"

procedure TForm1.adjustPanelTo(const aPanel: TPanel; aWcontrol: TWinControl); 
begin 
    if aPanel = nil then Exit; 
    if aWcontrol = nil then Exit; 
    if aWcontrol.Parent = nil then Exit; 

    aPanel.Parent := aWcontrol.Parent; 
    aPanel.Anchors := [akLeft, akTop]; 
    aPanel.Left := aWcontrol.Left + 1; 
    aPanel.Top := aWcontrol.Top + aWcontrol.ClientHeight - aPanel.Height; 
    aPanel.BringToFront; 
end; 

procedure TForm1.FormShow(Sender: TObject); 
begin 
    adjustPanelTo(Panel1, DBGrid1); 
end; 
+0

'Panel1.Top : = DBGrid1.ClientHeight - Panel1.Height; '이는 스크롤 막대 위에 패널을 놓고 스크롤 막대는 클라이언트가 아닌 영역의 일부입니다. –

+0

물론 솔루션이 패널을 위쪽으로 이동하려는 경우 부모를 수정할 필요가 없습니다. –

+0

패널이 표시되어있는 동안 스크롤 막대로 눈금을 스크롤하려 했습니까? 그것은 당신의 의견으로는 괜찮은가? 'TDBGrid'는 단순히 자식 컨트롤을 호스트하도록 설계되지 않았습니다. –

관련 문제