Click here to Skip to main content
15,882,063 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I just want some cells be selected to put a graphic design. If I able to call the paint event may sort out the problem contains the code to draw graphic.

The problem is after loading the form only the last cell selected shows the graphics. Any ideas

Winforms controls expose a method name Refresh().
Try it.
Share this answer
Reji Ab 29-Aug-12 7:02am    
It didn't work for me
for calling paint event pragmatically use,

Happy Coding!
Share this answer
Reji Ab 29-Aug-12 7:34am    
I want to call the paint event in the load event of the form. Invalidate doesn't call the paint event in the load event of the form
Aarti Meswania 29-Aug-12 7:45am    
may paint event is not giving desire output for,
"only the last cell selected shows the graphics"
control's invalidate always fire control's paint event
you can test your paint event code, put a button on form
onclick call grid.invalidate()
it will fire paint event.
after loading form click on that button if it still giving same view it means something wrong in paint event.
Reji Ab 29-Aug-12 8:48am    
There nothing wrong in the paint event. It works well after loading the form. I debug the code , it doesn't goes to the paint event when it executes invalidate in the form load event
[no name] 29-Aug-12 9:35am    
Why would you expect it to? There is nothing to paint in a form load.
Reji Ab 29-Aug-12 10:59am    
I want to paint the grid in form load event. Below is the bit of code in the load event. I want execute the paint event of the grid in the line "DbgridView.InvalidateCell(DbgridView.CurrentCell)"

For Each dr In dt.Rows If irow >= iTotalrows Then DbgridView.Rows.Add(1) End If DbgridView.Item(iColumn, irow).Value = dr("CT_DESC") If Not IsDBNull(dr("Assigned_Code")) Then selection = True rcdraw = DbgridView.GetCellDisplayRectangle(iColumn, irow, False) DbgridView.CurrentCell = DbgridView.Item(iColumn, irow) DbgridView.CurrentCell.Selected = True DbgridView.InvalidateCell(DbgridView.CurrentCell) End If irow = irow + 1 ' Exit Sub Next

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900