Board index » delphi » Accessing TFields at runtime
Mario Blataric
![]() Delphi Developer |
Sun, 21 Mar 2004 20:10:35 GMT
|
Mario Blataric
![]() Delphi Developer |
Sun, 21 Mar 2004 20:10:35 GMT
Accessing TFields at runtime
Hi!
I use TIBQuery to which I change SQL at runtime (couple of different SQLs). What I would like to do is that newly created fields would have proper DisplayLabel and DisplayFormat properties. I use couple of if commands to do that, but those field never get displayed that way in dxDBGrid. The problem is that I have to open IBQuery in order to access Fields, but when I open it, all columns get created in dxDBGrid, and then, when I do change DisplayLabel and DisplayFormat, there is no result in dxDBGrid. I would have to set those values before IBQuery gets opened but I don't know how. Anyone knows how to do this? Thanks! -- Mario Blataric |
Team
![]() Delphi Developer |
Sun, 21 Mar 2004 21:58:37 GMT
Re:Accessing TFields at runtimeQuoteMario Blataric wrote: 2. Open the IBQuery 3. Set DisplayLabel/Format 4. Reconnect the dxDBGrid to its datasource. HTH, -Craig -- |
Mario Blatari
![]() Delphi Developer |
Sun, 21 Mar 2004 22:42:51 GMT
Re:Accessing TFields at runtimeQuote> > The problem number formatting is performed, although I set them before. Here is the code: dxDBGrid1.DefaultFields:=False; When data is displayed, columns caption are 'ID_RAD_NALOG, BARKOD, ID_SKLAD Thanks, Mario Blataric |
Arno Brinkman [BISIT
![]() Delphi Developer |
Sun, 21 Mar 2004 23:16:37 GMT
Re:Accessing TFields at runtimeMaybe another solution ? Set SQL.Text with queries like this : SELECT And to Display it on a special way you could use then OnDrawColumnCell and procedure TfrmX.DBGridDrawColumnCell(Sender: TObject; const Rect: TRect; Greetz, Arno Brinkman. |
Team
![]() Delphi Developer |
Mon, 22 Mar 2004 00:17:50 GMT
Re:Accessing TFields at runtimeThis works for me. I tried this with 3 grids - DBGrid and two dxDBGrids. The first dxDBGrid had its DefaultFields set to true, the second (gdData) had it set to false and the columns created manually (all other properties the default settings). In all three cases the column was labeled correctly and the column displayed data correctly formatted. procedure TForm1.Button2Click(Sender: TObject); QuoteMario Blataric wrote: Jeff Overcash (TeamB) | Talk about failure (Please do not email | To fall is not to fail me directly unless | Failure isn't about falling down asked. Thank You) | Failure is staying down (Marillion) |
Mario Blatari
![]() Delphi Developer |
Mon, 22 Mar 2004 14:52:45 GMT
Re:Accessing TFields at runtimeI have tried all the possible combinations with dxDBGrid and DBGrid, DefaultFields, no DefaultFields, everything. No result. Grid always displays captions and formatting as reflection of table fields, and no formatting. I use IBX 4.63, Interbase 6.01, Delphi 5.01 Enterprise, Win2k. I am not sure about dx Version (I guess it does not matter, since DBGrid also does not work). I tried disconnecting grid from datasource and then reconnect it after table open, but fields are always default, and not as specified in DisplayLabel. The idea of Arno Brikman is great to solve captions, but I am not sure I Any ideas about this? Thanks, Mario Blataric |
Mario Blatari
![]() Delphi Developer |
Mon, 22 Mar 2004 15:18:00 GMT
Re:Accessing TFields at runtimeHi again. Problem solved. I think the problem is in programmers which always looks the sollutions in Thanks everyone. Mario Blataric |
RESO / Claude GUT
![]() Delphi Developer |
Tue, 23 Mar 2004 01:48:36 GMT
Re:Accessing TFields at runtimeI'm using the following : with MyIBQuery do procedure SetFieldDefs(UnDataset : TDataset); working fine with dxDBGrid. Mario Blataric <mario.blata...@vz.tel.hr> a crit dans le message : Quote> Hi! |
Wayne Niddery [TeamB
![]() Delphi Developer |
Tue, 23 Mar 2004 06:06:24 GMT
Re:Accessing TFields at runtimeQuote"Mario Blataric" <mario.blata...@vz.tel.hr> wrote in message Quote> Problem solved. -- |
1. How to create Persistent TFields at runtime????
2. Creating a TField-object (TMemoField) at runtime ?
3. Createing TFields at runtime
4. Creating TFields in runtime
5. Making and attaching a TField component to a TClientDataSet at runtime
6. What to know about making the TFields at runtime
7. Creating a TField at runtime
10. Making and attaching a TField component to a TClientDataSet at runtime