How do you highlight the row and/or column labels of a datagridview on mouseover of any cell (in c#)?

You could override the OnCellPainting event to do what you want. Depending on the size of your DataGridView you might see flickering, but this should do what you want.

You could override the OnCellPainting event to do what you want. Depending on the size of your DataGridView, you might see flickering, but this should do what you want. Class MyDataGridView : DataGridView { private int mMousedOverColumnIndex = int.

MinValue; private int mMousedOverRowIndex = int. MinValue; protected override void OnCellMouseEnter(DataGridViewCellEventArgs e) { mMousedOverColumnIndex = e. ColumnIndex; mMousedOverRowIndex = e.

RowIndex; base. OnCellMouseEnter(e); base.Refresh(); } protected override void OnCellPainting(DataGridViewCellPaintingEventArgs e) { if (((e. ColumnIndex == mMousedOverColumnIndex) && (e.

RowIndex == -1)) || ((e. ColumnIndex == -1) && (e. RowIndex == mMousedOverRowIndex))) { PaintColumnHeader(e, System.Drawing.Color.

Red); } base. OnCellPainting(e); } private void PaintColumnHeader(System.Windows.Forms. DataGridViewCellPaintingEventArgs e, System.Drawing.

Color color) { LinearGradientBrush backBrush = new LinearGradientBrush(new System.Drawing. Point(0, 0), new System.Drawing. Point(100, 100), color, color); e.Graphics.

FillRectangle(backBrush, e. CellBounds); DataGridViewPaintParts parts = (DataGridViewPaintParts. All & ~DataGridViewPaintParts.

Background); e. AdvancedBorderStyle. Right = DataGridViewAdvancedCellBorderStyle.

None; e. AdvancedBorderStyle. Left = DataGridViewAdvancedCellBorderStyle.

None; e. Paint(e. ClipBounds, parts); e.

Handled = true; } }.

You can hook into the DataGridView's CellMouseEnter and CellMouseLeave events and then change the backcolor accordingly. Something like this: private void dataGridView1_CellMouseEnter(object sender, DataGridViewCellEventArgs e) { if (e. RowIndex ColumnIndex LightBlue; } private void dataGridView1_CellMouseLeave(object sender, DataGridViewCellEventArgs e) { if (e.

RowIndex DataGridView1.Rowse.RowIndex.Cellse.ColumnIndex.Style. BackColor = Color. White; }.

I want to change the row label (the fixed column to the left) just like it changes when you move the mouse over it. – Stuart Helwig Jun 3 '09 at 11:35 Oh, my bad, I thought you meant you wanted that to happen for the cells themselves. Let me mess around a bit more... – BFree Jun 3 '09 at 11:38.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions