Member Avatar for Lioshenka

Hello again,

I am doing my second project now and I am using database components. So when I run the application and the DBGrid is shown and the data is read in from the MS Acess database, all the fields are too big and you have to scroll horizontally. Is there any way in auto-resizing them accordingly to the text they contain, or can i set their default values to, say, 40 pixels?

It is not required to pass my course, it is just me being trying to make it look good.

It would be very appreciated if someone can not only post a piece of code but also show me where to declare all the variables etc!

Thanks in advance.

PS I heard there is ColWidths property, but it only applies to StringGrid if I am correct...

Member Avatar for Micheus

So when I run the application and the DBGrid is shown and the data is read in from the MS Acess database, all the fields are too big and you have to scroll horizontally.

Doesn't You used to add columns to the TDBGrid? Becose this way You can resize columns at design-time.
You can set field's property DisplayWidth too, but this is in character size - not pixels.

Is there any way in auto-resizing them accordingly to the text they contain, or can i set their default values to, say, 40 pixels?

I think isn't a good idea. You must read all rows in dataset result looking for the most long size string to proceed auto-size.


p.s. sorry my poor english.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.