Solved

DBgrid columns

Posted on 2001-08-31
4
279 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
ID: 6444434
try using TClientDataset


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

Expert Comment

by:Mohammed Nasman
ID: 6444512
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:
Mohammed Nasman earned 25 total points
ID: 6444873
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
ID: 6445405
Ok thanks changing at runtime & order is done in sql code :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

910 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

26 Experts available now in Live!

Get 1:1 Help Now