Solved

Sizing Columns of a dbgrid at runtime

Posted on 2006-11-27
5
223 Views
Last Modified: 2010-04-05
hi everybody
i am facing a problem with dbgrids.
i am using a single grid for displaying data of different tables. each table is having different number of fields.
so when assinging the query to the grid at runtime ... in some tables where number of fields is less empty space is left at the right of the grid .. and when the number of fields are more a horizontal scrollbar appears on the grid.
i want my form size to remain the same.
i hope the question is understood.

thanks in advance
0
Comment
Question by:Asmitagoyal
5 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 18025839
>i hope the question is understood.
not really, what is wrong with the scrollbar and the free space(if there are less columns)?
thats a kind of dynamic, which keeps your form in the current metrics

nevertheless you can adjust the column-width like (preferable in the afteropen-event of your dataset)

  dbgrid1.Columns[index].Width := ...

meikl ;-)

0
 

Author Comment

by:Asmitagoyal
ID: 18025894
hello
using dbgrid1.Columns[index].Width := ... is a cumbersome task
i've to know the width of all the fields in advance ... which is not possible.
i don't want neither the extra free space nor the scroll bar .
if there is any other method for this ...... kindly suggest
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 18025906
>if there is any other method for this
no, not as i know ->
you have to calculate the width byself depending on count of fields and type of field

meikl ;-)
0
 
LVL 10

Expert Comment

by:atul_parmar
ID: 18025940
>using dbgrid1.Columns[index].Width := ... is a cumbersome task
>i've to know the width of all the fields in advance ... which is not possible.

cumbersome??? Asmita, if you think this way, there is NO way.

You don't need to know the width of all fields. You can write a generic routine which can work for all tables. Let me know if you need more help on this.
0
 
LVL 11

Accepted Solution

by:
calinutz earned 500 total points
ID: 18026164
A solution to your problem can be found here:
But there is a lot of work to do left...

http://delphi.about.com/od/usedbvcl/l/aa050404a.htm


regards
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

830 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