I am having difficulty determining how to set the default font for rows in an UltraGrid on the fly at runtime. Is this possible and if so, how?
I can change it during initialization using the Font property, but that changes everyrow, even headers and only works prior to the grid being initialized. I need something that works dynamically, in response to user input, for example.
Thanks,
Doug
Sandip,
Yes, I am sorry. I was not they clear in my original post. I hope this makes it more clear.
I have a grid that is displayed with data. Next to that grid, I have a button that the user can press to display a dialog box with options to configure the appearence of the grid. Of those, is the Font. They can select font name, size, bold, italics, underline, and color. Once they set those options to their satisfaction, they click OK and the modifications should be immediately reflected in the grid, i.e. new font, color, size, style as it was changed.
I have not been able to get this to work. Only if the grid is closed and recreated, i.e. new font parameters set when it is initialized, do the changes take effect.
Thanks for your persistence and help!
Hi Doug,
InitializeRow will get raised whenever the row's cell values change. You can even force InitializeRow event to be raised on all rows using the grid.Rows.Refresh method in case you need to re-set fonts on all rows. Having said that, which properties that you need to set are read-only? Maybe I'm misunderstainding what you are trying to accomplish, in which case can you clarify.
Sandip
I was not able to get this to work because the properties for row in the InitializeRow event handler are read-only. Also, I need this to change on-demand after the grid is built and displayed in response to user input, not at initialization. Is this even possible or am I totally missing something really basic?
You can do this by hooking into InitializeRow event of the grid and initialize the row.Appearance based on your criteria.
Appearance blueApp, redApp;
// init above appearances.
// in InitializeRow event handler, assign the row's Appearance to whichever appearance object is applicable to the row based on your criteria.
e.Row.Appearance = blueApp;
This will greatly reduce memory overhead since the same blue or read appearance object will be shared across multiple rows.