Scrollable DataGrid with background image..

  • Thread starter Thread starter Iulian Ionescu
  • Start date Start date
I

Iulian Ionescu

For the purposes of a presentation I had to design a datagrid with the following properties: the cell's background is painted with a 50% transparent color and a bitmap with a logo is displayed in the background of the grid. This is all achieved in the OnPaint for the Grid and Paint for the DAtaGridColumn. Everything works perfectly with one problem: when you try to scroll the grid up or down the background image scrolls too (as this is the way the win32 scroll does it) and only the new portion is invalidated. Of course that was quite ugly so I overrode the GridVScroll and I added a refresh after. What happens is that the background still goes up or down with the scroll and then "snaps" back, when the refresh fires... I would like to know how can I prevent an additional repainting or how can I force the scroll to just scroll the view port (so the new cells are displayed) but do not draw anything? Should I listen to WM_SCROLL and add an invalidate() before? Can someone please help?

Thank you,
iulian
 
Just wondering. Could you put a picturebox and/or panel behind the datagrid, then in the OnPaint event of the DG paint the DG background transparent 50% so the picturebox behind it will show?
For the purposes of a presentation I had to design a datagrid with the following properties: the cell's background is painted with a 50% transparent color and a bitmap with a logo is displayed in the background of the grid. This is all achieved in the OnPaint for the Grid and Paint for the DAtaGridColumn. Everything works perfectly with one problem: when you try to scroll the grid up or down the background image scrolls too (as this is the way the win32 scroll does it) and only the new portion is invalidated. Of course that was quite ugly so I overrode the GridVScroll and I added a refresh after. What happens is that the background still goes up or down with the scroll and then "snaps" back, when the refresh fires... I would like to know how can I prevent an additional repainting or how can I force the scroll to just scroll the view port (so the new cells are displayed) but do not draw anything? Should I listen to WM_SCROLL and add an invalidate() before? Can someone please help?

Thank you,
iulian
 
Have you tried using Datagrid.SuspendLayout to stop any
paint refreshes and then invoking Datagrid.ResumeLayout
after your refresh?
-----Original Message-----
For the purposes of a presentation I had to design a
datagrid with the following properties: the cell's
background is painted with a 50% transparent color and a
bitmap with a logo is displayed in the background of the
grid. This is all achieved in the OnPaint for the Grid
and Paint for the DAtaGridColumn. Everything works
perfectly with one problem: when you try to scroll the
grid up or down the background image scrolls too (as this
is the way the win32 scroll does it) and only the new
portion is invalidated. Of course that was quite ugly so
I overrode the GridVScroll and I added a refresh after.
What happens is that the background still goes up or down
with the scroll and then "snaps" back, when the refresh
fires... I would like to know how can I prevent an
additional repainting or how can I force the scroll to
just scroll the view port (so the new cells are
displayed) but do not draw anything? Should I listen to
WM_SCROLL and add an invalidate() before? Can someone
please help?
 
Back
Top