Solved

Sizing Columns of a dbgrid at runtime

Posted on 2006-11-27
5
225 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
[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
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

Technology Partners: 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 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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 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