|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DataGrid OnPaint/? -How Do I Draw A GDI Type Circle On Top Of A DataGridMy main form uses a MyDataGrid. instance as the folowing code from MyDataGrid.cs public class MyDataGrid : DataGrid .. protected override void OnPaint(PaintEventArgs e) { base.OnPaint (e); } On my small datagrid it hits this code about a 100 or so times, it seems it's painting each cell, headers, etc individually with all that TableStyles stuff. Where in my code would I do the circle painting thing. Or, where in my code am I after it finishes with this OnPaint. Is this done in my main form, or do I need to do it somewhere in MyDataGrid.cs that it hits after it's done with the OnPaint? I would suggest that this could best be accomplished using the LayeredWindow API in a NativeWindow derived class. Drawing directly onto the desktop is possible but has refresh problems. A NativeWindow could be made a child of the DataGrid window and therefore clip to the area of the datagrid automatically.
-- Bob Powell [MVP] Visual C#, System.Drawing Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm All new articles provide code in C# and VB.NET. Subscribe to the RSS feeds provided and never miss a new article. "Richard" <a@b.com> wrote in message news:qrl1e.86466$534.31813@twister.nyc.rr.com... I want to put a GDI type circle on top of my DataGrid (actually I want to put GDI colored border around the entire selected row, but if I can figure out how to put a circle on top of it I can do the border) My main form uses a MyDataGrid. instance as the folowing code from MyDataGrid.cs public class MyDataGrid : DataGrid . protected override void OnPaint(PaintEventArgs e) { base.OnPaint (e); } On my small datagrid it hits this code about a 100 or so times, it seems it's painting each cell, headers, etc individually with all that TableStyles stuff. Where in my code would I do the circle painting thing. Or, where in my code am I after it finishes with this OnPaint. Is this done in my main form, or do I need to do it somewhere in MyDataGrid.cs that it hits after it's done with the OnPaint? I was able to subclass the DataGrid and override the OnPaint. It drew a nice GDI border around a row. I hard coded it. I'm sure there are a myriad of potential show stoppers with this method. One is I hope I'll be able to figure a way to put the border on the right place on the screen over the DataGrid for the selected row. I'll have to probably somehow get the number of pixels on the drawing area down from the top of the visible x,y of the datagrid control, etc.?
Any pointers (no pun intended)? protected override void OnPaint(PaintEventArgs pe) { base.OnPaint(pe); // Create pen. Pen blackPen = new Pen(Color.Green, 2); // Create location and size of rectangle. float x = 15.0F; float y = 53.0F; float width = 500.0F; float height = 20.0F; } pe.Graphics.DrawRectangle(blackPen, x, y, width, height); "Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message news:OPqHapsMFHA.2136@TK2MSFTNGP14.phx.gbl... I would suggest that this could best be accomplished using the LayeredWindow API in a NativeWindow derived class. Drawing directly onto the desktop is possible but has refresh problems. A NativeWindow could be made a child of the DataGrid window and therefore clip to the area of the datagrid automatically.-- Bob Powell [MVP] Visual C#, System.Drawing Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm All new articles provide code in C# and VB.NET. Subscribe to the RSS feeds provided and never miss a new article. "Richard" <a@b.com> wrote in message news:qrl1e.86466$534.31813@twister.nyc.rr.com... I want to put a GDI type circle on top of my DataGrid (actually I want to put GDI colored border around the entire selected row, but if I can figure out how to put a circle on top of it I can do the border) My main form uses a MyDataGrid. instance as the folowing code from MyDataGrid.cs public class MyDataGrid : DataGrid . protected override void OnPaint(PaintEventArgs e) { base.OnPaint (e); } On my small datagrid it hits this code about a 100 or so times, it seems it's painting each cell, headers, etc individually with all that TableStyles stuff. Where in my code would I do the circle painting thing. Or, where in my code am I after it finishes with this OnPaint. Is this done in my main form, or do I need to do it somewhere in MyDataGrid.cs that it hits after it's done with the OnPaint?
REALbasic 5.5 free to VB6 Users Untili March 31 2005
spice the boring default winforms treeview appearance up a bit... Help with SendMessage API calls Error with Custom Control Closing form... e.Cancel = True in MDI Child Closing event Friend WithEvents Object reference not set to an instance of an object. Tabcontrol tabpagebutton orientation Form Load Event |
|||||||||||||||||||||||