raffeo
2018-11-14T09:32:26Z
Hi.
I have a question. I'm tryng to set a cell style (ex. style_number) for a column.

grid.Cols[columnname].CellStyle = style_number;

but the style continue to be null.

Instead if I apply the style to a cell (grid.Rows[rownumber].Cells[columnname].Style = style_number) it works.

The problem is for default values becaus doesn't apply correct style.

Can someone help me to understand?

Thanks in advance
Igor/10Tec
2018-11-14T15:34:08Z
Can you reproduce the problem in a brand new project and send it to us for the further consideration?
raffeo
2018-11-15T15:17:07Z
Hi Igor,
it's very easy to reproduce.

Make a grid, create a cell style with, for example, a formatstring ({0:N2}).
Now apply this style to the column with grid.Cols[columnname].CellStyle = style_number;

I image that this instruction apply the style to the new cell by default.

If you add row to the grid and at the column (columnname) I don't set any value , igrid set the default value.
Now If I check grid.Rows[rownumber].Cells[columnname].Style it is null.

Working with the grid I found an other problem too... always working with fixed cell style.

If i set backcolorevenrows and backcoloroddrows and after I apply some style to a column the grid lose color for even and odd rows.
I image that backcolorevenrows and backcoloroddrows is priority on the cell style



Igor/10Tec
2018-11-15T15:33:32Z
Originally Posted by: raffeo 

Now If Icheck grid.Rows[rownumber].Cells[columnname].Style it is null.


Yes, this is by design. The column cell style (grid.Cols[columnname].CellStyle) and the cell style of a cell in this column (grid.Rows[rownumber].Cells[columnname].Style) are two different objects. The first defines the general look of cells in the column, and it is used if a cell does not have its own style. If you assign a cell style object to the Style property of the cell, the settings of this object overrides the corresponding settings from the column cell style.

Originally Posted by: raffeo 

If i set backcolorevenrows and backcoloroddrows and after I apply some style to a column the grid lose color for even and odd rows. I image that backcolorevenrows and backcoloroddrows is priority on the cell style


No, cell styles have precedence over these properties.
raffeo
2018-11-15T15:47:49Z
First problem.
Ok if I set value for a cell and so define the style too. But if i don't set value (and igrid set default value) I can't set style. In the second option I think it could be right
apply the generalk look of the cell (the style applied on the column)

Second problem
I don't think it is correct to manage two different style for the cell (styleodd and styleeven) when there is a property on the grid.
Igor/10Tec
2018-11-16T08:11:08Z
Send us a project demonstrating the issue we are talking about. It's hard to understand what is wrong just reading text description.