I use the code below to change the display format of one column so the decimal only display two numbers after the dot, but it didn't work. I also use the design models to set the format property of one column, again, it didn't work. Is there any reason?
ultraGridZYYWSR.DisplayLayout.Bands[0].Columns["percent"].Format = "##0.###";
Hi there,
use the following:
ultraGridZYYWSR.DisplayLayout.Bands[0].Columns["percent"].Format ="#,#0.#0";
Hope that helped
Nassos
reyzidis said: ultraGridZYYWSR.DisplayLayout.Bands[0].Columns["percent"].Format ="#,#0.#0";
this seems didn't work too.
Ah, okay. I was going to mention that, but your original post specifically says decimal.
I have 2 suggestions:
1) If you set properties at design-time, then you have to be very careful about how you bind the grid at run-time. If your data source doesn't match up with the structure you have defined at design-time, then the grid will throw away the layout and create a new one based on the new data source you are using at run-time. Also, you must bind the grid at run-time using the SetDataBinding method - you should not be setting the DataSource or DataMember properties. So I would suggest putting a button on the form to display the Format property of the column and see if it is still set to the same value you set at design-time so you can see if it is somehow getting lost.
Personally, I prefer to do everything in the InitializeLayout event of the grid to avoid these kinds of issues.
2) Format only applies to a cell that is not in edit mode. When a cell is in edit mode, then it uses the Mask properties instead of Format.