Quaneu
2016-07-15T07:10:39Z
Hello,

is it possible to change the background of a cell if the row is selected?

I tryed this:

CustomDrawCellBackground += Grid_CustomDrawCellBackground;
...
row.Cells[index].CustomDrawFlags = iGCustomDrawFlags.Background;
...
private void Grid_CustomDrawCellBackground(object sender, iGCustomDrawCellEventArgs e)
{
	color = Color.Aquamarine; // Only for testing!!!
	using (Brush brush = new SolidBrush(color))
	{
		e.Graphics.FillRectangle(brush, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
	}
}

Grid_CustomDrawCellBackground() was called, and all cells have the backgound "Aquamarine" but in the selected Row all cells have the background from the property SelCellsBackColor. I want that all cells have the backgound Aquamarine.

Best regards
Quaneu
Quaneu
2016-07-21T13:43:04Z
Igor/10Tec
2016-07-22T11:20:29Z
We don't understand why you can't simply set the SelCellsBackColor property to the background color of your cells. Or you can set the HighlightSelCells property to False. Or maybe, we simply do not understand your task...
Quaneu
2016-07-23T07:58:01Z
I tried this. But without success.

For example:

SelCellsBackColor = green

Row 1: white white red red orange (not selected)
Row 2: green green red red orange (selected)
Row 3: white blue red red orange (not selected)
Igor/10Tec
2016-07-25T07:25:20Z
It seems, we need a sample that demonstrates the issue. And it would be nice to have an accompanying screenshot.

Please, do not include the bin/obj subfolders of the solution into the archive.
Quaneu
2016-07-25T07:42:31Z
At first a screenshot:

Screenshot.PNG

Click to View Image240 View(s)



The first row is the selected. Therefore all cells have the gray backgound. But for example the first cell in the selected row
should has the same color as the cell under their (light red).
Igor/10Tec
2016-07-25T07:58:42Z
Do you want to overwrite the background color only for some cells in the selected row? Send us an example that shows your grid settings, please.
Quaneu
2016-07-25T08:10:41Z
Quote:

Do you want to overwrite the background color only for some cells in the selected row?


Yes.


internal class Grid : iGrid
{
public Grid()
{
	RequestCellToolTipText += Grid_RequestCellToolTipText;
	KeyDown += grid_KeyDown;
	CustomDrawCellBackground += Grid_CustomDrawCellBackground;

	RowMode = true;
	ImageList = GenericImageList.ImageList;
	ForeColor = SystemColors.ControlText;
	SelRowsForeColor = SystemColors.ControlText;
	SelCellsBackColor = SystemColors.ControlLight;
	SelCellsForeColor = SystemColors.ControlText;
	DefaultRow.Height = 22;
	DefaultRow.NormalCellHeight = 22;
	DefaultRowHeightAutoSet = false;
}
private void Grid_CustomDrawCellBackground(object sender, iGCustomDrawCellEventArgs e)
{

	Color color= Color.Yellow; // Only for test!!!

	using (Brush brush = new SolidBrush(color))
	{
		e.Graphics.FillRectangle(brush, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
	}
}
}

All other Properties have default values and all cells have the value "iGCustomDrawFlags.Background" in "CustomDrawFlags".
Igor/10Tec
2016-07-25T08:43:08Z
As I see, you use row mode. In this case the whole row is selected, and the SelRowsBackColor color "covers" your cells in the selected row - even if they have custom-drawn background.

To gain the goal you need (show the real background of the required cells), you can try a semi-transparent selection color in the SelRowsBackColor property.

And BTW, in your first post you asked us about changing the selection color for ALL cells in the selected row.
Quaneu
2016-07-25T10:04:50Z
Quote:

And BTW, in your first post you asked us about changing the selection color for ALL cells in the selected row.


Sorry, you're right. In the first line i wrote "of a cell" and than "all cells"...

With a semi-transparent selection color it works perfect, thanks.