Home Forums WinForms controls Xceed Grid for WinForms Grid Drawing Reply To: Grid Drawing

User (Old forums)
Post count: 23064

I don’t think the GridControl has a specific method for doing this. But the GridControl is just a Control, and I think you can send a WM_PRINT message to a control, that will make the control paint itself onto a device context you specify.<code>using System.Drawing;
using System.Windows.Forms;

public class ControlPainter
private const int WM_PRINT = 0x317, PRF_CLIENT = 4;

private static extern int SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, int lParam);

public static void PaintControl(Control control, Graphics graphics)
IntPtr hWnd = control.Handle;
IntPtr hDC = graphics.GetHdc();
SendMessage(hWnd, WM_PRINT, hDC, PRF_CLIENT);
If you try this (untested code), could you let me know if it worked?

Imported from legacy forums. Posted by Tommy (had 171 views)