Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
45
Setting Column CellAppearance stops HotTrack Working
posted

Firstly I am using AppStylist setting the Base->Row  HotTracked Background Color to PaleGreen.

On my Windows Form the grid appears as designed in the AppStylist with the HotTrack on rows showing Pale Green. However when I change the color of some columns as below the CellAppearance stops the HotTrack working for the columns where the color has been changed. The other columns continue to display the HotTrack correctly.

gridMain.DisplayLayout.Bands[0].Columns["colX"].CellAppearance.BackColor = System.Drawing.Color.Yellow;

Adding the line of code below after changing the column's cell appearances makes no difference.

gridMain.DisplayLayout.Bands[0].Override.HotTrackRowAppearance.BackColor = Color.Red;

Why does this happen and what would be the correct method to change the back color of some columns and still allow the HotTrack to work for all columns?

Parents
No Data
Reply
  • 469350
    Offline posted

    Hi,

    As a general rule of thumb, the grid tries to resolve the more specific appearance and give it precedence over a less specific appearance.

    In some cases, this can be hard to define. Which is more specific, a column or a row? In this case, it looks like it was decided that the column is more specific than a row, so the column's CellAppearance gets resolved first.

    In code, the grid has ways to handle this. In addition to the HotTrackRowAppearance, there is also a HotTrackRowCellAppearance, which affects the cells in the hot-tracking row. This appearance takes precedence over the CellAppearance of a column.

    However, I don't see any way to do this in AppStyling. There isn't any way to translate this into UIRoles or states, since it's basically another appearance that applies to the same UIRole (UltraGridRow) and the same state (HotTracking).

    So the only way I can see the achieve what you want is... do not set any appearance on the UltraGridRow's HotTracking state in your isl file. Instead, simply create a Resource in the isl file with the HotTracking colors you want. Then, in code, you can set the HotTrackRowCellAppearance.StyleResourceName property to the name of the resource. This allows you to define the HotTracking appearance on the row in your isl file, and still have it override the CellAppearance on the column.

    The down side is that it requires a single line of code for each grid you are using.

Children