Some GDI/GDI+ fun with the WinForms DataGrid control

I've published a new article on MSDN that details how you can add some nifty visual effects to the WinForms DataGrid control when dragging and dropping columns. Constructive criticism is more than welcome. I'm also looking for ideas for my next article, so if there's anything in the area of GDI/GDI+ that you're interested in seeing, please don't hesitate to let me know.

Comments

  • Anonymous
    August 04, 2004
    Just a thought - you could make the dragged column transparent by using:

    // draw bitmap image
    if ( ShowColumnWhileDragging || ShowColumnHeaderWhileDragging ) {
    float[][] colorMatrixPoints ={
    new float[] {1, 0, 0, 0, 0},
    new float[] {0, 1, 0, 0, 0},
    new float[] {0, 0, 1, 0, 0},
    new float[] {0, 0, 0, 0.5f, 0},
    new float[] {0, 0, 0, 0, 1}};
    ColorMatrix colorMatrix = new ColorMatrix(colorMatrixPoints);
    ImageAttributes imgAttributes = new ImageAttributes();
    imgAttributes.SetColorMatrix(colorMatrix,
    ColorMatrixFlag.Default,
    ColorAdjustType.Bitmap);

    g.DrawImage(m_draggedColumn.ColumnImage,
    new Rectangle(m_draggedColumn.CurrentRegion.X, m_draggedColumn.CurrentRegion.Y, m_draggedColumn.ColumnImage.Width, m_draggedColumn.ColumnImage.Height),
    0, 0, m_draggedColumn.ColumnImage.Width, m_draggedColumn.ColumnImage.Height,
    GraphicsUnit.Pixel, imgAttributes);
  • Anonymous
    August 04, 2004
    That's awesome. Thanks, Daren!
  • Anonymous
    August 18, 2004
    I'm having a great time with Chris's data grid. It's my first time using Microsoft's data grid and data sources, and as I keep delving into it, I get more and more pleased. The initial complexity of the control is well worth it when you see what you can do with it.

    The example above (with ColorMatrix) reminds me of something: There really aren't very good examples of doing all possible manipulations with the ColorMatrix, especially operations involving Matrix Rotations and Shears (like doing gamma corrections, and rotating Hue around the blue axis)

    Fortunately, I remembered Paul Haeberli's stuff for SGI, http://www.sgi.com/software/opengl/advanced97/notes/node142.html#SECTION000142450000000000000

    Also, .Net seems to lack Matrix math fuctions. This is an unfortunate omission. (I wanted to derive my own ColorMatrix to add some of these functions, but the class is "sealed"!)
  • Anonymous
    March 31, 2008
    PingBack from http://collegefunfactsblog.info/sano-the-super-geek-some-gdigdi-fun-with-the-winforms-datagrid-control/