System.Windows.Forms.ThemeWin32Classic.DataGridPaintParentRow C# (CSharp) Method

DataGridPaintParentRow() public method

public DataGridPaintParentRow ( Graphics g, Rectangle bounds, System.Windows.Forms.DataGridDataSource row, System.Windows.Forms.DataGrid grid ) : void
g System.Drawing.Graphics
bounds System.Drawing.Rectangle
row System.Windows.Forms.DataGridDataSource
grid System.Windows.Forms.DataGrid
return void
		public override void DataGridPaintParentRow (Graphics g, Rectangle bounds, DataGridDataSource row, DataGrid grid)
		{
			// Background
			g.FillRectangle (ResPool.GetSolidBrush (grid.ParentRowsBackColor),
					 bounds);

			Font bold_font = new Font (grid.Font.FontFamily, grid.Font.Size, grid.Font.Style | FontStyle.Bold);
			// set up some standard string formating variables
			StringFormat text_format = new StringFormat();
			text_format.LineAlignment = StringAlignment.Center;
			text_format.Alignment = StringAlignment.Near;

			string table_name = "";
			if (row.view is DataRowView)
				table_name = ((ITypedList)((DataRowView)row.view).DataView).GetListName (null) + ": ";
			// XXX else?

			Rectangle	text_rect;
			Size		text_size;

			text_size = g.MeasureString (table_name, bold_font).ToSize();
			text_rect = new Rectangle(new Point(bounds.X + 3, bounds.Y + bounds.Height - text_size.Height), text_size);

			g.DrawString (table_name,
				      bold_font, ResPool.GetSolidBrush (grid.ParentRowsForeColor), text_rect, text_format);

			foreach (PropertyDescriptor pd in ((ICustomTypeDescriptor)row.view).GetProperties()) {
				if (typeof(IBindingList).IsAssignableFrom (pd.PropertyType))
					continue;

				text_rect.X += text_rect.Size.Width + 5;

				string text = String.Format ("{0}: {1}",
							     pd.Name,
							     pd.GetValue (row.view));

				text_rect.Size = g.MeasureString (text, grid.Font).ToSize();
				text_rect.Y = bounds.Y + bounds.Height - text_rect.Height; // XXX

				g.DrawString (text,
					      grid.Font, ResPool.GetSolidBrush (grid.ParentRowsForeColor), text_rect, text_format);
			}

            // Paint Borders
			if (!grid.FlatMode) {
                CPDrawBorder3D (g, bounds, Border3DStyle.RaisedInner, 
                    Border3DSide.Left | Border3DSide.Right | 
                    Border3DSide.Top | Border3DSide.Bottom);
			}
		}
ThemeWin32Classic