Hi,
{
UltraGridColumn col = new UltraGridColumn("icon", null, ColumnType.Button, null);
col.CellStyle.BackColor = col.CellStyle.ForeColor = System.Drawing.Color.Transparent;
col.CellButtonStyle.BorderStyle = BorderStyle.None;
col.CellButtonStyle.BorderWidth = Unit.Pixel(0);
col.CellStyle.TextOverflow = TextOverflow.Ellipsis;
UltraWebGrid1.Columns.Add(col);
}
Thanks, Christian
I'd start by moving this into the IntializeLayout event.
For me, I have to set the Cell.BackColor during .InitializeRow because I have to change the color based on the data being loaded in the cell. Using .InitializeLayout would be fine, if all cells were being set to the same color, but in my case they are not. The problem only occurs when there is a PostBack caused by another event such as adding a new row to the grid, or selecting an item from another control, andthing that would cause a PostBack and refresh the screen.
I do do all my intial grid setup in the InitializeLayout, but my case of changing individual cell colors bases on the data loaded into them, I have to set the background color for those cells in the InitializeRow event. My problem, just as it is with the original poster of this thread is that my cells loose the background colors I set when ever there is a PostBack of the page. I have thought about putting my code in the PreRender event of the grid as well, but I don't think that will make a difference. It's like the grid is loosing some of the property settings that are setup in code when a PostBack occurs.
Thank you,Eric Ritzie
You should set all the layout options (how you want the grid to look) in Initialize Layout or by changing grid properties (aspx file or use quick design, or... you know :o), if that is an option).
I had grid button problems before. I tried to set the background image in Initialize Layout method. In Firefox, the image would showup fine, but on some systems in IE it would not (depending on windows settings). I solved this by setting the button background to gray (any color would do, but you have to set it to something). So it looks like this:
<CellButtonStyle BackColor="LightGray" BackgroundImage="/images/cancel.png" Height="23px" Width="23px" />
I do not know why this is happening, but if you look at the resulting HTML for the background image button, it really looks funky. Maybe somebody knows more about this and can explain why :o)
I hope this helps.