Resizing columns


If I use ColumnSize/ColumnStretch I can choose to stretch only one column. But, is it possible to stretch multiple (custom selected) columns? For example, column 0 is the icon column and that column does not to be resized but all other columns should resize. How to do that?

When you use column stretching, the column to be stretched is set with grid.ColumnSize.StretchColumn. When it is -1, it defaults to the last (rightmost) column.

I know that. But that doesn't solve the problem I described: I don't won't all columns to be stretched or just one. I only need exactly specific columns to be effected.

Then you will need to programmatically call grid.AutoSizeCol(columnindex) for these columns where you need it.

I have merged Column 0 and 1, 3 and 4, 5 and 6
I have 14 Columuns
I don't want to strech the merged columns 3 and 4, 5 and 6

How can I do this?

I'm sorry but your question is unclear to me.
If you merge cells with grid.MergeCells and do NOT call grid.AutoSizeCol() no column size will be affected.

I don't want to autosize the columns coz this will not solve my problem. Autosizing only will size the columns to the needed width for showing the content, but this ist not what I want.

I only want to stretch specific columns except columns 3 and 5. 3 and 5 have a fixed width.

As I already explained, column stretching is set with grid.ColumnSize.Stretch / grid.ColumnSize.StretchColumn. When it is -1, it is the last column that is being stretched.

This answer doesn't belong to my question....

That is what I was interested in the first place but gave up :D

Great that you've understood the question ;) We have the same problem... but no solution

If you see someone struggling to understand your question,

wouldn't it be helpful to try to make it more detailed, more informative, more clear instead of blaming the listener?

Hi Bruno,

I think I explained in the first post what is the problem: If I use ColumnSize/ColumnStretch I can choose to stretch only one column.But I would need something like ColumnStretch = 2 & 3 (ONLY columns 2 and 3 should automatically stretch, NOT others).

That is the problem. I need other columns not to change size but only the columns 2 and 3. But, the property ColumnStretchallows to define only one column that automatically stretches.

As I explained, the column stretching feature is limited to 1 column you can select. This is how it is designed. The alternatives are using grid.AutoSizeCol() or set the column size of any column programmatically with grid.ColumnSize[index]: integer.

Thanks for the answer. Didn't know it is limited to only 1 column.