Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Sizing Columns of a dbgrid at runtime

Posted on 2006-11-27
5
Medium Priority
?
243 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 1000 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

916 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