Hi
I am trying to turn off/disable the default blue highlight that shows when a row is selected in the grid.
This is needed because, I mark certain cells in certain rows with a red background to denote negative values.
Unfortunately the blue colored row highlight overrides this red background for the row that i set selected and the entire row is highlighted in red.
I was able to turn off the row level highlight by using the below line in the AfterCellActivate event.
MyFacilityRatingCustom.Grid.DisplayLayout.Override.ActiveRowAppearance.Reset()
But I am not able to disable the activatedcell highlight. The active cells till highlights in White.
The below statement doesnt work
MyFacilityRatingCustom.Grid.DisplayLayout.Override.ActiveCellAppearance.Reset()
The grid's default Preset sets colors on the ActiveRowAppearance and ActiveCellAppearance. Resetting these in the AfterCellActivate is very inefficient and redundant. You should just reset these two property in the designer at design time - you don't need to do it in code every time the cell activates.
I agree to that.
For some reason I am not able to rest the property from designer mode. So I put in code in the Init of the form.
Moreover, resetting only seems to work for Row. The ActiveCellAppearance doesnt seem to work for me. The activecell is still highlighted in White. So I am forced to have the cellappearance set to whatever color the cell is by coding an the cell level event.
Setting the SelectTypeCell uses a white background, but for this I will have to do away with tracking which selection the user has done. But this is not possible since the requirement is to track user selection and apply appropriate business logic.
Use of CellClickAction is also not appropriate in this situation since the cells are not to be made editable, but needs to be selectable.
.DisplayLayout.Override.ActiveRowAppearance.Reset()
The above code makes sure that no highlights are used for the row. Thus the background colors of each individual cell in that row shows through and is not hidden by any highlight. But...
.DisplayLayout.Override.ActiveCellAppearance.Reset()
does not seem to behave the same. It still highlights the current selected cell with a white background thus hiding any custom background color that was set to the cell.
So I believe to keep my custom highlights for the cells to be visible, I will have to be using BeforeCellActivate event to explicitly override the highlight color for the selected/active cell.
Thanks for the pointers though, Mike.
Okay, I think there's some confusion here.
The ActiveCellAppearance that is applied by default is not blue, it's white. So if you cell is showing up blue, it means that the cell is probably selected and this has nothing to do with the ActiveCellAppearance.So maybe you need to set SelectTypeCell to None or CellClickAction to something that does not select the cell.
I am not sure why this is happening and I couldn't get time to investigate on that further.
The property seems to set in the designer mode, but once I hit the run button the setting reverts back.
I believe it could probably be because of some other inhouse custom layout components that are present in the designer.
What puzzles me though is the reason cell reset wouldnt work.
I tried calling the below statements in the InitializeLayout event, but all that it results in is the active cell being highlighted in blue. The active row aint highlighted though and the statement for the row reset call seems to work.
.DisplayLayout.Override.ActiveRowAppearance.Reset() //This works
.DisplayLayout.Override.ActiveCellAppearance.Reset() //This doesnt work
Anyways for the moment I have a rather inefficient workaround by using the BeforeCellActivate event, but the issue still puzzles me.
Why can't you reset the properties at design-time?
There's no reason this should not work. Nor is there any reason I can think of why it would not work at run-time. Unless you are somehow re-setting the appearances after you reset them. Maybe you are loading a layout or a preset that has these properties set?