CRDBGrid Column Width disregarding settings

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
geekman1024
Posts: 16
Joined: Wed 25 Feb 2009 04:29

CRDBGrid Column Width disregarding settings

Post by geekman1024 » Tue 07 Sep 2010 03:01

Environment:
MyDAC 5.90.0.58
Borland C++ Builder 6 Enterprise
Win XP Pro SP3

Problem:
This may be a very noob problem, but I have been buggered by it for some time, and couldn't find any similar problem with the forum search.

The CRDBGrid will occasionally disregard the column width I set for the columns and expend the width no matter how I set the column size or OptionsEx->Stretch. The columns will just expend beyond the width I demanded and causing the horizontal scroll bar to appear.

I want all my columns to appear in the exact area I set for the Grid, i.e. I can see all columns in one glimpse. This behavior of disregarding the option and width limit is causing quite a lot of headache.

Anyone know how to make this bad kid (CRDBGrid) behave as being told?

more details:
My Grid accommodates a query result from a JOIN of 2 tables resulting of 23 columns, but I only display 10 of them, since some columns are meant for system use, not for the user to see, so those are not added to the column list of the Grid. Each column is set to 60 px, so it's well within the Grid width (650 px).

However upon running the application (The columns are behaving nicely while in design time), all the columns will expend to about 100 px (roughly estimation by eye), causing some of the columns have to be scrolled to be revealed, not to mention that the overly widened columns are so ugly to see. Some of the columns contains decimal (5,2) data and some contains enum('A', 'B', 'C', 'D', 'E', 'F') data. 100 px is definitely tooooooo wide for such data.

I doubt the widening has anything to do with the table being JOIN-ed (thus the 'hidden' columns), since I have encountered the same problem from a single table with all columns added.

Sometimes if I set the OptionsEx->Stretch to true may solve the problem (the columns is stretched nicely), but sometimes it won't help a bit, the columns still expend for no apparent reason.

Any help? Thanks in advance.

Image
Image: this is how the Grid looks like at design time.


Image
Image: this is how it looks like at run time the last 2 columns have been pushed out of the grid's default display area.
Last edited by geekman1024 on Tue 07 Sep 2010 03:59, edited 3 times in total.

geekman1024
Posts: 16
Joined: Wed 25 Feb 2009 04:29

Post by geekman1024 » Tue 07 Sep 2010 03:19

Correction:
The columns that are auto expanding are those with decimal(5,2), the enum fields are not changing, or may be they were contracting, but since the column title is limiting the shrink size, so it is not too obvious.

The Grid is behaving correctly during design time, columns are not changing when I activate or deactivate the query, but the column size changing will happen when in run time.

More clue:
Font size may have a part of the reason - Originally I used 10 pt fonts, but later changed the font size back to the default 8 pt, since the fonts are smaller, 60px is well enough to accommodate the decimal(5,2) data, so no expansion required, but this is not the problem, the problem is the columns are disregarding my width setting and options setting.

geekman1024
Posts: 16
Joined: Wed 25 Feb 2009 04:29

Post by geekman1024 » Tue 07 Sep 2010 03:42

Even more clue:

Using the multi-row column title is causing the OptionsEx->Stretch to not working. If I set some of the column name to for example "Values|Data 1", "Values|Data 2", etc, the columns will disregard the Stretch option and the column width I set.

If I remove the multi row column title, the Stretch option will work, and my problem will be partially solved (expanding and shrinking will still happen, but is controlled by the Stretch option behavior).

Oh and by the way, why is the root row (i.e. the "Values" row in my example above) of the column title not centered even when I set the alignment to taCenter? The 2nd row will be centered correctly, but the first row will always be left-justified. This is so ugly.

Image
Image: this is how the Grid would look like if I remove the multi-row column title. note that the Mark columns are expanded, while the Grade columns are shrunk. However the columns are still within the default display area.



Image
Image: multi-row column title not formatted properly.

AndreyZ

Post by AndreyZ » Tue 07 Sep 2010 13:01

Hello,

The TCRDBGrid component is free, and it is no longer developed.
MyDAC includes sources of TCRDBGrid. So you can modify it as you like.

geekman1024
Posts: 16
Joined: Wed 25 Feb 2009 04:29

Post by geekman1024 » Wed 08 Sep 2010 03:23

That's a very sad news, I'm a C++ programmer, not a Pascal programmer, the source is totally useless to me.

I might be able to understand the Pascal source code, but I'm not familiar with Pascal syntax and grammar, and I don't have time to learn another language just to be able to cleanup other programmer's mess.

-1 point for MyDAC.

Post Reply