Solved

DBgrid columns

Posted on 2001-08-31
4
280 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

816 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

12 Experts available now in Live!

Get 1:1 Help Now