Documents
NextGrid & NextDBGrid
- Html Column Tutorial
- Upgrade existing projects for loading changes
- NextGrid Vista Style
- Edit events in NextGrid
- NextGrid How To
- Integrating Inplace Editors
- InputLine Tutorial
- NextGrid Slide Style Tutorial
- FieldChooser Tutorial
- Using Editors in runtime
- Grid Report Tutorial
NextGrid
- TreeColumn Tutorial
- NextGrid Quick Start
- Custom Draw in NextGrid
- Export to XML from NextGrid
- Optimize NextGrid
- NextGrid Custom Sorting
- VirtualColumn Tutorial
- Graphic Column Tutorial
NextDBGrid
- NextDBGrid Quick Start
- NextDBGrid Events
- NextDBGrid How To
- Sorting records in NextDBGrid
- LookupColumn Tutorial
NextInspector
- NextInspector Advanced tutorial
- ToolbarItem tutorial
- NextDBInspector Tutorial
- NextInspector Item Types
- Map VCL property to item
- NextInspector Quick Start
NextSheet
NextCollection
- NxAlertWindow Tutorial
- NxInfoPanel Tutorial
- Vista Styled Panels
- NxPathControl and NxNotebook tutorial
- NxPathControl Quick Start
- NxFlipPanel and NxHeaderPanel Quick Start
- NxOutlookBar Tutorial
- NxPageControl and NxNotebook Quick Start
- NxButton Tutorial
Misc
- Component Names Change
- NxComboBox styles
- Numeric FormatMask
- NxVirtualDataSet tutorial
- DateTime FormatMask
- NxPreview Quick Start
- 32bit Bitmaps Tutorial
- Quick update
- Enable typing unicode characters in InplaceEditors
- Using NxColorScheme
- NxProgress Tutorial
- NxAutoCompletion Tutorial
Labs
NextGrid .NET
- Working with tree
- Custom Drawing in NextGrid dot NET
- NextGrid Dot Net
- NextGrid Dot Net Events
- NextGrid dot NET Quick Start
Custom Drawing in NextGrid dot NET
Related Articles:
Info
- Skill:
- Version: 1.0.0
- Author: Bojan Nikolic
- Created: 2010-12-30
- Updated: 2011-02-06
1. How cell is painted
First background color is painted. It is painted in Cell's Color (BackColor property). If Cell is selected, it is filled with SelectionColor color. Then, content of the Cell is painted.
2. Set column for custom draw
Cell is not drawn in custom mode by default. This is controled by DrawingOptions property of Column:
Name | Meaning |
---|---|
Normal | Cells within this column are drawn without custom draw. |
Custom | Cell will be drawn as usuall, but custom code may be added as extra painting layer on top over existing drawing. |
CustomOnly | Cell must be drawn manualy, even a background |
ContentOnly | Only Cell's content is drawn without Background of Cell being drawn. |
BackgroundOnly | Background is drawn as first layer (may be selected or not), but additional drawing must be done manualy. |
3. CustomDrawCell event
CustomDrawCell event occurs for all cells that are currently on screen. This event consists of parameters that can be used to identify cell which is currently painted, and status of this cell.
Name | Meaning |
---|---|
e | Object containing Graphics property. |
x | Determine column index of currently painting cell. |
y | Determine row index of currently painting cell. |
CellRectangle | Determine Rectangle of currently painting cell. |
selected | Determine selected status of currently painting cell. |
focused | Determine if currently painting cell is focused. |
4. Example
Next example use Cell's Rectangle and shrink it by 2px on each side. Then, if cell is selected draw rectangle in red color. If cell is not selected it will be painted in green color.
To draw graphics elements into grid we need to use Graphics property of e parameter.
DrawingOptions of Column should be set to BackgroundOnly.
private void nextGrid1_CustomDrawCell(object sender, PaintEventArgs e, int x, int y, Rectangle CellRectangle, bool selected, bool focused) { CellRectangle.Inflate(-2, -2); if (selected) { e.Graphics.FillRectangle(new SolidBrush(Color.Red), CellRectangle); } else { e.Graphics.FillRectangle(new SolidBrush(Color.Lime), CellRectangle); } }