?
Solved

DBgrid columns

Posted on 2001-08-31
4
Medium Priority
?
284 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 100 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month10 days, 8 hours left to enroll

765 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