| | |
is it possible to set backgroundimage to selected cell
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
dataGridView1.Rows[Row].Cells[ColName].Style.SelectionBackColor =your color(Color.Red)
for image find this link:
http://msdn.microsoft.com/en-us/libr...nt(VS.80).aspx
for image find this link:
http://msdn.microsoft.com/en-us/libr...nt(VS.80).aspx
Last edited by viswa_007; Oct 31st, 2008 at 7:16 am.
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
yes you can, and with a small amount of imagination it was very obvious and very simple. In fact MSDN shows almost how to do it, it shows how you draw something for a given cell and it took me like 2 minutes of my life which I bothered to do.
And you guys wonder why I get narked? Tiny amount of reading of msdn.
where b is a bitmap loaded in or such.
And you guys wonder why I get narked? Tiny amount of reading of msdn.
where b is a bitmap loaded in or such.
C# Syntax (Toggle Plain Text)
e.PaintContent(e.CellBounds); if (dataGridView1.CurrentCell.RowIndex == e.RowIndex && dataGridView1.CurrentCell.ColumnIndex == e.ColumnIndex) { e.Graphics.DrawImage(b, e.CellBounds); } else { e.PaintBackground(e.CellBounds, true); } e.Handled = true;
Last edited by LizR; Nov 3rd, 2008 at 6:30 am.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
•
•
Join Date: Jul 2008
Posts: 66
Reputation:
Solved Threads: 6
•
•
•
•
yes you can, and with a small amount of imagination it was very obvious and very simple. In fact MSDN shows almost how to do it, it shows how you draw something for a given cell and it took me like 2 minutes of my life which I bothered to do.
And you guys wonder why I get narked? Tiny amount of reading of msdn.
where b is a bitmap loaded in or such.
C# Syntax (Toggle Plain Text)
e.PaintContent(e.CellBounds); if (dataGridView1.CurrentCell.RowIndex == e.RowIndex && dataGridView1.CurrentCell.ColumnIndex == e.ColumnIndex) { e.Graphics.DrawImage(b, e.CellBounds); } else { e.PaintBackground(e.CellBounds, true); } e.Handled = true;
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
I just noticed it pasted it funny.
That drawcontents should be just before the handled line not the first. Otherwise yes the background ovewrites it but you would have noticed that..
That drawcontents should be just before the handled line not the first. Otherwise yes the background ovewrites it but you would have noticed that..
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
•
•
Join Date: Jul 2008
Posts: 66
Reputation:
Solved Threads: 6
ya the image s overlapping in cellpainting event ,so if i added before the image , im drawing the string means each and every time the cellpainting event s firing whenever mouse enters to the grid.so the problwm s lot of records s available in grid. every time its drawing text based on clicked content.any more suggestion.
![]() |
Other Threads in the C# Forum
- Previous Thread: Looking for a project to join
- Next Thread: How can I print a PDF file using .net tech
Views: 1360 | Replies: 10
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access algorithm array barchart bitmap box button buttons c# chat check checkbox class client code color combobox control conversion csharp custom database datagridview dataset datetime degrees draganddrop drawing encryption enum excel file files form format forms ftp function gdi+ httpwebrequest image index input install java label list listbox listener login mandelbrot math mouseclick mysql networking object operator oracle path photoshop picturebox pixelinversion post prime programming radians regex remote remoting resource richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml






