Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Resize Fixed Column Width at runtime

576 views
Skip to first unread message

Enoch Ng

unread,
Dec 6, 2000, 8:48:09 PM12/6/00
to
Hello there,

I have set 'goColSizing' of TStringGrid to true. When I move the mouse
pointer to the FixedRows, it allows me to resize the width of the column.
However, when I move to mouse pointer to the FixedCols (the area where the
FixedRows and FixedCols overlap), I cannot resize the width of this column.

So, how can I resize the width of the fixed column at run time?

Thanks.

--
Best regards,

Enoch Ng,

Giuliano

unread,
Dec 6, 2000, 11:20:05 PM12/6/00
to
On Thu, 7 Dec 2000 09:48:09 +0800, "Enoch Ng" <en...@intellect.com.hk> wrote:

[snip]


>So, how can I resize the width of the fixed column at run time?

Have a look at ColWidths property of string grid.

StringGrid->ColWidths[which column] = <width in pixel>;

For example:

StringGrid->ColWidths[0] = 120;

Hope this helps

Ciao

Giuliano

Mark Cashman

unread,
Dec 7, 2000, 3:00:00 AM12/7/00
to
Hi, Enoch!

The only way I've found is to set fixed cols to 0 and then simulate it
myself using owner draw.

You can draw the 0th col to always show the contents of the grid col 0
rather than the current (real) leftmost and can color the column grey in
the OnDrawCell handler. And you can ignore mouse clicks on it by using
the OnSelectCell event handler.

With this done, the columns can be resized. The only problem with that
may be that you will need to manage the actually column sizes very
carefully, since the user will be changing the width of the leftmost col
which won't always be col 0.

------
Mark Cashman (TeamB - C++ Builder), creator of The Temporal Doorway at
http://www.temporaldoorway.com
- Original digital art, writing, music and more -
C++ Builder / JBuilder Tips and The C++ Builder Programmer's Webring
(Join us!)
http://www.temporaldoorway.com/programming/index.htm
------

Enoch Ng

unread,
Dec 10, 2000, 8:36:07 PM12/10/00
to
Hi Mark,

Thank you for the solution. I understand your method and it is what I need.
However I am afraid there are many things to be implemented if the grid
supports scrolling. The fixed column should be fixed when the user scroll
horizontally. When I scroll it, no OnDrawCell event on that virtual fixed
column will be triggled. So, the virtual fixed column will be replaced by
the next column and the virtual fixed column will disappeared. How can I
solve it?

Thanks.

"Mark Cashman" <mcas...@temporaldoorway.com> ?????
news:3A301CD9...@temporaldoorway.com...

Mark Cashman

unread,
Dec 11, 2000, 8:23:45 PM12/11/00
to
Hi, Enoch!

This is the tricky part. You have to determine which column is the
leftmost and pretend it is col 0 in the OnDrawCell

if (ACol == TheGridInQuestion->LeftCol)
{
// This is the fake col 0, so draw in the Col 0 data, not the
real column data.

Does that make sense?

Jackie Yeh

unread,
Dec 18, 2000, 5:51:35 AM12/18/00
to
The fixed columns have the 3D effect, that's why they looked like the fixed
columns.
How can I do to make the columns have 3D effect?

Enoch Ng wrote:

--
Yeh Lung-chuan(葉龍泉)
Jackie Yeh
Software engineer
Rayson Technology Co., Ltd.
jack...@ms7.url.com.tw
jack...@mail.rayson.com
O:+886-3-5633666-218
M:+886-930-051103
ICQ:17918151


Enoch Ng

unread,
Jan 2, 2001, 2:40:21 AM1/2/01
to
Hi Mark,

I have tried your solution but I still have a problem. Let's say we have
100 Columns and 10 columns is currently displayed with 1 column is a fixed
column. When you click the right scroll button, only the
OnDrawCell() on next column has been triggered, that is, 11th column. The
first column (that fixed column) will be replaced by the second column
automatically by the TStringGrid. You have no way to refresh the OnDrawCell
on the fixed column. How can I solve this?

Thanks..

"Mark Cashman" <mcas...@temporaldoorway.com> ?????
news:3A357E21...@temporaldoorway.com...

Enoch Ng

unread,
Jan 2, 2001, 2:42:29 AM1/2/01
to
Hi Jackie,

I think you can draw the 3D effect on the DrawCell method yourselves.

"Jackie Yeh (葉龍泉)" <jack...@ms7.url.com.tw> ?????
news:3A3DEC37...@ms7.url.com.tw...

Mark Cashman

unread,
Jan 3, 2001, 7:58:40 PM1/3/01
to
Hi, Enoch!

I thought I had answered this. Anyway, you have to be prepared to draw
the content of the 0th col into the leftmost visible col, no matter
which that is.

0 new messages