The Ask:
Using WiseJ v2.2 I’m looking to update a DataGridViewImageColumn’s icon (.svg) color based on the grid row’s “hovered” and “selected” states. Any help insight on how to do this is much appreciated.
Is there a location/correlation to the DataGridViewImageColumn and a property in the .theme file where “inherit” could be leveraged?!
Background:
I’ve found within the .Theme file how/where to set the text color of a grid’s selected row when the state changes from “default”, “hovered”, “selected”, etc. However I can’t seem to find the proper location within the theme file to affect/alter a DataGridViewImageColumn’s icon (.svg) color.
This is similar to the post here: “https://wisej.com/support/question/listview-set-icon-color-on-states” but for a grid instead of a listview. Ideally there is a location in the .theme file on one of the controls and or sub components: “table”, “table-button-cell”, “table-cell”, “table-checkbox-cell”, “table-combobox-cell”, “table-image-cell”, or “table-row”.
Table-Image-Cell seem to be the most promising, but it only seems to support “inherits”: “table-cell” from all the samples in the WiseJ Theme Builder. Table-Cell next promising but not sure where in the .theme file the component or sub-component for “icon” should exist.
Alternative Approach:
Setting the icons color based on the “grid_SelectionChanged” event in the code behind works, however there is a half second delay to updating the icon/color. This is a poor user experience. I’m looking for an instantaneous solution, to align with how the text color updates.
private void grid_SelectionChanged(object sender, EventArgs e)
{
..if (sender is DataGridView dgv && dgv.SelectedRows.Count <= 1)
..{
….foreach (DataGridViewRow row in dgv.Rows)
….{
……if (row.Selected)
……{
……..row.Cells[1].Style.BackgroundImageSource = “Images\\preview.svg?color=red”;
……}
……else
……{
……..row.Cells[1].Style.BackgroundImageSource = “Images\\preview.svg?color=blue”;
……}
….}
..}
}
Hi Chad,
For the cell there is no hovered state since it’s handled in javascript and the cells are not widgets, they are plain html.
You can use simple css but SVG images by default don’t support recoloring.
The easiest way is to set the cell content to HTML and use standard css, etc.
Best regards
Frank
Please login first to submit.