0

I am using TDBCtrl Grid, and I can only see one record to see next record I have to scroll however I have set RowCount=5. Also, my dbgridCTRL can only allow TDBEdit or TEdit controls. I want to display static text also. Can you please suggest How can I display the Labels on DBCTRL Grid.

enter image description here

This is how the currently looks like. The Rans Member etc are staticText control. However I want to display multiple records at the same time.

object DBCtrlGrid1: TDBCtrlGrid
  Left = 4
  Top = 2
  Width = 215
  Height = 122
  AllowDelete = False
  AllowInsert = False
  DataSource = DSCredit
  PanelHeight = 122
  PanelWidth = 199
  TabOrder = 0
  RowCount = 1
  OnPaintPanel = DBCtrlGrid1PaintPanel
end
Arioch 'The
  • 15,799
  • 35
  • 62
user2809635
  • 139
  • 1
  • 3
  • 12
  • get yourself a more potent grid like the one from devexpress (not free, but worth every penny) – whosrdaddy Dec 19 '13 at 06:56
  • 1
    @whosrdaddy Thats noce advice, but I cannot have that. I want to do it with DBCtrl Grid – user2809635 Dec 19 '13 at 06:58
  • Then you will have to modify/adapt the existing grid control, there are enough resources on this subject on the net, google a bit around... – whosrdaddy Dec 19 '13 at 07:07
  • Are trying to access the hatched area in the IDE, which is not intended to place controls on it, since controls will be rendered in this places on runtime? (According to the controls placed on the non hatched area) Controls seemingly placed there indeed are placed on the parent of the DBCtrlGrid (Wincontrols will be visible since they are other then graphic controls are not painted on the from directly): This can be seen just by moving the DBCtrlGrid around after placing contols on the hatched/non hatched part. – bummi Dec 19 '13 at 08:34
  • I am placinbg the controls on Hatched Area. any how, can u please tell me how to display multiple records and not rows in the griod I want atleast 3-5 records, dont want scroll – user2809635 Dec 19 '13 at 09:16
  • What's the Height of your DBCtrlGrid according to the Object Inspector? Maybe append the text version of your DFM to the question. Also OS and Delphi version? – MartynA Dec 19 '13 at 09:23
  • This is the dfm as test for DBCTRLGrid:- object DBCtrlGrid1: TDBCtrlGrid Left = 4 Top = 2 Width = 215 Height = 122 AllowDelete = False AllowInsert = False DataSource = DSCredit PanelHeight = 122 PanelWidth = 199 TabOrder = 0 RowCount = 1 OnPaintPanel = DBCtrlGrid1PaintPanel end What I want is to display 3 or 5 records at a time without having to scroll them – user2809635 Dec 19 '13 at 09:37
  • `PanelHeight = 122` and `Height = 122` and 122/122 = 1. Exactly 1 row can fit when the row panel size is the same as the total size of the gird and hence one row is visible. I thin kyou have to resize the grid and the panel so several panels could fit the grid. – Arioch 'The Dec 19 '13 at 09:46

1 Answers1

0

Height == PanelHeight * RowCount. And same for widths/columns.

You have to set sizes of panels and girds in a way, that several panels would fit inside the visible area of the grid. If the panel size is the same as the total size of all panels - then thereis just no places for other panels being visible.

PS. x-ref https://stackoverflow.com/questions/20658435/


Below is the example of DFM with the controls inside the Control Grid. The DFM example above shows empty grid without internal controls.

object Form9: TForm9
  Left = 0
  Top = 0
  Caption = 'Form9'
  ClientHeight = 390
  ClientWidth = 635
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object grid1: TDBCtrlGrid
    Left = 48
    Top = 38
    Width = 217
    Height = 300
    PanelHeight = 100
    TabOrder = 0
    object pnl1: TPanel
      Left = 0
      Top = 16
      Width = 185
      Height = 41
      Caption = 'pnl1'
      TabOrder = 0
      object dbedt1: TDBEdit
        Left = 48
        Top = 11
        Width = 121
        Height = 21
        TabOrder = 0
      end
    end
  end
end
Community
  • 1
  • 1
Arioch 'The
  • 15,799
  • 35
  • 62
  • Tried this but it doesnt work as it sets both heights same as rows count is 1 and if I increased the row count still the only first row display the records when I click the remaining empty rows it navigates. I think my controls are not gettingh repeating across the rows.. – user2809635 Dec 19 '13 at 10:21
  • In your prior question i gave you a link about implementing repeatable controls, you used it ? Looking at the screenshot i just cannot see whether you can fit two panels - then each panel would become too small to accommodate for *all the buttons your squeezed into*. You better arrange them in a way that panel can be smaller than now and still all controls were visible. Last but not least - try from clean ground. Just set the empty DBCtrlGrid and see if it can have multiple panels visible, then go and add your components one after another and see which component would make grid single-row. – Arioch 'The Dec 19 '13 at 10:26
  • I have set the row count as 1 because if I set 3 it shows me 3 panels, and I dragged the controls on panel 1. the other two panels are hashed panels.When I move my grid the controls remain there it appears they are not the part of grid. I want them to be part of grid so that for multiple records i can show at least 3 or 5 records. The multiple panels are visible. I dragged the controls on first panel. The labels I drag seem to be gone in the background. Please help me with this. because I know it is possible in delphi.. – user2809635 Dec 19 '13 at 10:44
  • "because if I set 3 it shows me 3 panels, and I dragged the controls on panel 1. the other two panels are hashed panels" I think your expectations may be wrong: At design-time yes, that is how it will display (only showing one record, I mean), because of the way the DBCtrlGrid works but it should show multiple records at run time provided it has room and the dataset has more than one row. Normally the DBCtrlGrid "just works" so it must be something you are doing wrong, I think. – MartynA Dec 19 '13 at 10:53
  • "I dragged the controls on first panel" that doesnot work. The control belongs where you created it - dragging it just changes coords. And you can see it in DFM text structure. So start with empty 4-rows DBCTrlGrid and put TDBEdit onto its 1st panel, run and see oif you see three panels wiot hthree replicated edits. Then add second edit and so on – Arioch 'The Dec 19 '13 at 10:58
  • I did that it does not repeat the edit controls.. Only one set of control is visible no matter how many records are there and increasing RowCount also dnt help. – user2809635 Dec 19 '13 at 13:53
  • i said starting with one TDBEdit (placed on the panel, not dragged to it) and nothing else. Currently i suspect your panel has too many controls and cannot shrink its size – Arioch 'The Dec 19 '13 at 13:55