Solved

Sizing Columns of a dbgrid at runtime

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month8 days, left to enroll

617 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