Solved

DBgrid columns

Posted on 2001-08-31
4
278 Views
Last Modified: 2010-04-06
Hi,

i got an mdb access file, and i'm linking to it using a Tdatasource wich is connected to a TadoQuerry
and the dbgrid is connected to the Tdatasource

so i get my *wanted info* based on a querry and this is displayed in the dbgrid.

The columns are automaticly put in some order and the widths are also done automaticly, how can i do this manually io defining them in design time so they are for example all 50 pixels wide ?

i tried serveral things :
adding some columns using columns editor  but then my info wasn't displayed anymore

activating the querry in design time and modifying the width but then i couldn't change all of the columns (those strings defined in the access file 255 chars)
and also when i ran the program it was all reset.

so my question is how can i predefine these column widths and the order they appear in etc

thanks

0
Comment
Question by:joyrider
  • 2
4 Comments
 
LVL 1

Expert Comment

by:ntony
Comment Utility
try using TClientDataset


you can use EmptyDataSet,FieldDefs,CreateDataset to create the Dataset.
0
 
LVL 22

Expert Comment

by:mnasman
Comment Utility
This code will change all the colums in dbgrid to 50 width

procedure TForm1.Button1Click(Sender: TObject);
var
  I : integer;
begin
  for I := 0 to DBGrid1.Columns.Count -1 do
    DBGrid1.Columns[I].Width := 50;
end;
0
 
LVL 22

Accepted Solution

by:
mnasman earned 25 total points
Comment Utility
and about the fileds order
you can change it from the sql statment
don't 'use select *',
use the field names
'select field1, field3, field2 from table'
0
 

Author Comment

by:joyrider
Comment Utility
Ok thanks changing at runtime & order is done in sql code :)
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now