i'm displaying some rows in DatagridView
which will have first column as ImageandText.when user selects any row i would like to select till the cell with text portion by keeping the image background as white.
Code used for displaying the image and text in first cell of DataGridView :
private void dgvLogDetails_CellPainting(object sender,
DataGridViewCellPaintingEventArgs e)
{
if (e.RowIndex >= 0 && e.ColumnIndex == 0)
{
e.PaintBackground(e.ClipBounds, true);
PointF p = e.CellBounds.Location;
e.CellStyle.SelectionBackColor = Color.White;
p.X += imgList.ImageSize.Width+8;
e.Graphics.DrawImage(imgList.Images[1], e.CellBounds.X+4,
e.CellBounds.Y, 16, 16);
e.Graphics.DrawString(e.Value.ToString(),
e.CellStyle.Font, Brushes.Black, p);
e.Handled = true;
}
}
the above code selects the complete cell (image and text) as shown in below picture:
i wanted to have something like in below picture [Expected]:
Tried Sriram code and it is showing as below: